ortools.constraint_solver.pywrapcp
1# This file was automatically generated by SWIG (http://www.swig.org). 2# Version 4.0.1 3# 4# Do not make changes to this file unless you know what you are doing--modify 5# the SWIG interface file instead. 6 7from sys import version_info as _swig_python_version_info 8if _swig_python_version_info < (2, 7, 0): 9 raise RuntimeError("Python 2.7 or later required") 10 11# Import the low-level C/C++ module 12if __package__ or "." in __name__: 13 from . import _pywrapcp 14else: 15 import _pywrapcp 16 17try: 18 import builtins as __builtin__ 19except ImportError: 20 import __builtin__ 21 22def _swig_repr(self): 23 try: 24 strthis = "proxy of " + self.this.__repr__() 25 except __builtin__.Exception: 26 strthis = "" 27 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) 28 29 30def _swig_setattr_nondynamic_instance_variable(set): 31 def set_instance_attr(self, name, value): 32 if name == "thisown": 33 self.this.own(value) 34 elif name == "this": 35 set(self, name, value) 36 elif hasattr(self, name) and isinstance(getattr(type(self), name), property): 37 set(self, name, value) 38 else: 39 raise AttributeError("You cannot add instance attributes to %s" % self) 40 return set_instance_attr 41 42 43def _swig_setattr_nondynamic_class_variable(set): 44 def set_class_attr(cls, name, value): 45 if hasattr(cls, name) and not isinstance(getattr(cls, name), property): 46 set(cls, name, value) 47 else: 48 raise AttributeError("You cannot add class attributes to %s" % cls) 49 return set_class_attr 50 51 52def _swig_add_metaclass(metaclass): 53 """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" 54 def wrapper(cls): 55 return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) 56 return wrapper 57 58 59class _SwigNonDynamicMeta(type): 60 """Meta class to enforce nondynamic attributes (no new attributes) for a class""" 61 __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) 62 63 64import weakref 65 66class DefaultPhaseParameters(object): 67 r""" This struct holds all parameters for the default search. DefaultPhaseParameters is only used by Solver::MakeDefaultPhase methods. Note this is for advanced users only.""" 68 69 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 70 __repr__ = _swig_repr 71 CHOOSE_MAX_SUM_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_SUM_IMPACT 72 CHOOSE_MAX_AVERAGE_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_AVERAGE_IMPACT 73 CHOOSE_MAX_VALUE_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_VALUE_IMPACT 74 SELECT_MIN_IMPACT = _pywrapcp.DefaultPhaseParameters_SELECT_MIN_IMPACT 75 SELECT_MAX_IMPACT = _pywrapcp.DefaultPhaseParameters_SELECT_MAX_IMPACT 76 NONE = _pywrapcp.DefaultPhaseParameters_NONE 77 NORMAL = _pywrapcp.DefaultPhaseParameters_NORMAL 78 VERBOSE = _pywrapcp.DefaultPhaseParameters_VERBOSE 79 var_selection_schema = property(_pywrapcp.DefaultPhaseParameters_var_selection_schema_get, _pywrapcp.DefaultPhaseParameters_var_selection_schema_set, doc=r""" This parameter describes how the next variable to instantiate will be chosen.""") 80 value_selection_schema = property(_pywrapcp.DefaultPhaseParameters_value_selection_schema_get, _pywrapcp.DefaultPhaseParameters_value_selection_schema_set, doc=r""" This parameter describes which value to select for a given var.""") 81 initialization_splits = property(_pywrapcp.DefaultPhaseParameters_initialization_splits_get, _pywrapcp.DefaultPhaseParameters_initialization_splits_set, doc=r""" Maximum number of intervals that the initialization of impacts will scan per variable.""") 82 run_all_heuristics = property(_pywrapcp.DefaultPhaseParameters_run_all_heuristics_get, _pywrapcp.DefaultPhaseParameters_run_all_heuristics_set, doc=r""" The default phase will run heuristics periodically. This parameter indicates if we should run all heuristics, or a randomly selected one.""") 83 heuristic_period = property(_pywrapcp.DefaultPhaseParameters_heuristic_period_get, _pywrapcp.DefaultPhaseParameters_heuristic_period_set, doc=r""" The distance in nodes between each run of the heuristics. A negative or null value will mean that we will not run heuristics at all.""") 84 heuristic_num_failures_limit = property(_pywrapcp.DefaultPhaseParameters_heuristic_num_failures_limit_get, _pywrapcp.DefaultPhaseParameters_heuristic_num_failures_limit_set, doc=r""" The failure limit for each heuristic that we run.""") 85 persistent_impact = property(_pywrapcp.DefaultPhaseParameters_persistent_impact_get, _pywrapcp.DefaultPhaseParameters_persistent_impact_set, doc=r""" Whether to keep the impact from the first search for other searches, or to recompute the impact for each new search.""") 86 random_seed = property(_pywrapcp.DefaultPhaseParameters_random_seed_get, _pywrapcp.DefaultPhaseParameters_random_seed_set, doc=r""" Seed used to initialize the random part in some heuristics.""") 87 display_level = property(_pywrapcp.DefaultPhaseParameters_display_level_get, _pywrapcp.DefaultPhaseParameters_display_level_set, doc=r""" This represents the amount of information displayed by the default search. NONE means no display, VERBOSE means extra information.""") 88 decision_builder = property(_pywrapcp.DefaultPhaseParameters_decision_builder_get, _pywrapcp.DefaultPhaseParameters_decision_builder_set, doc=r""" When defined, this overrides the default impact based decision builder.""") 89 90 def __init__(self): 91 _pywrapcp.DefaultPhaseParameters_swiginit(self, _pywrapcp.new_DefaultPhaseParameters()) 92 __swig_destroy__ = _pywrapcp.delete_DefaultPhaseParameters 93 94# Register DefaultPhaseParameters in _pywrapcp: 95_pywrapcp.DefaultPhaseParameters_swigregister(DefaultPhaseParameters) 96 97class Solver(object): 98 r""" Solver Class A solver represents the main computation engine. It implements the entire range of Constraint Programming protocols: - Reversibility - Propagation - Search Usually, Constraint Programming code consists of - the creation of the Solver, - the creation of the decision variables of the model, - the creation of the constraints of the model and their addition to the solver() through the AddConstraint() method, - the creation of the main DecisionBuilder class, - the launch of the solve() method with the decision builder. For the time being, Solver is neither MT_SAFE nor MT_HOT.""" 99 100 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 101 __repr__ = _swig_repr 102 INT_VAR_DEFAULT = _pywrapcp.Solver_INT_VAR_DEFAULT 103 r""" The default behavior is CHOOSE_FIRST_UNBOUND.""" 104 INT_VAR_SIMPLE = _pywrapcp.Solver_INT_VAR_SIMPLE 105 r""" The simple selection is CHOOSE_FIRST_UNBOUND.""" 106 CHOOSE_FIRST_UNBOUND = _pywrapcp.Solver_CHOOSE_FIRST_UNBOUND 107 r""" Select the first unbound variable. Variables are considered in the order of the vector of IntVars used to create the selector.""" 108 CHOOSE_RANDOM = _pywrapcp.Solver_CHOOSE_RANDOM 109 r""" Randomly select one of the remaining unbound variables.""" 110 CHOOSE_MIN_SIZE_LOWEST_MIN = _pywrapcp.Solver_CHOOSE_MIN_SIZE_LOWEST_MIN 111 r""" Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variables is the one with the lowest min value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.""" 112 CHOOSE_MIN_SIZE_HIGHEST_MIN = _pywrapcp.Solver_CHOOSE_MIN_SIZE_HIGHEST_MIN 113 r""" Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variable is the one with the highest min value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.""" 114 CHOOSE_MIN_SIZE_LOWEST_MAX = _pywrapcp.Solver_CHOOSE_MIN_SIZE_LOWEST_MAX 115 r""" Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variables is the one with the lowest max value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.""" 116 CHOOSE_MIN_SIZE_HIGHEST_MAX = _pywrapcp.Solver_CHOOSE_MIN_SIZE_HIGHEST_MAX 117 r""" Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variable is the one with the highest max value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.""" 118 CHOOSE_LOWEST_MIN = _pywrapcp.Solver_CHOOSE_LOWEST_MIN 119 r""" Among unbound variables, select the variable with the smallest minimal value. In case of a tie, the first one is selected, "first" defined by the order in the vector of IntVars used to create the selector.""" 120 CHOOSE_HIGHEST_MAX = _pywrapcp.Solver_CHOOSE_HIGHEST_MAX 121 r""" Among unbound variables, select the variable with the highest maximal value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.""" 122 CHOOSE_MIN_SIZE = _pywrapcp.Solver_CHOOSE_MIN_SIZE 123 r""" Among unbound variables, select the variable with the smallest size. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.""" 124 CHOOSE_MAX_SIZE = _pywrapcp.Solver_CHOOSE_MAX_SIZE 125 r""" Among unbound variables, select the variable with the highest size. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.""" 126 CHOOSE_MAX_REGRET_ON_MIN = _pywrapcp.Solver_CHOOSE_MAX_REGRET_ON_MIN 127 r""" Among unbound variables, select the variable with the largest gap between the first and the second values of the domain.""" 128 CHOOSE_PATH = _pywrapcp.Solver_CHOOSE_PATH 129 r""" Selects the next unbound variable on a path, the path being defined by the variables: var[i] corresponds to the index of the next of i.""" 130 INT_VALUE_DEFAULT = _pywrapcp.Solver_INT_VALUE_DEFAULT 131 r""" The default behavior is ASSIGN_MIN_VALUE.""" 132 INT_VALUE_SIMPLE = _pywrapcp.Solver_INT_VALUE_SIMPLE 133 r""" The simple selection is ASSIGN_MIN_VALUE.""" 134 ASSIGN_MIN_VALUE = _pywrapcp.Solver_ASSIGN_MIN_VALUE 135 r""" Selects the min value of the selected variable.""" 136 ASSIGN_MAX_VALUE = _pywrapcp.Solver_ASSIGN_MAX_VALUE 137 r""" Selects the max value of the selected variable.""" 138 ASSIGN_RANDOM_VALUE = _pywrapcp.Solver_ASSIGN_RANDOM_VALUE 139 r""" Selects randomly one of the possible values of the selected variable.""" 140 ASSIGN_CENTER_VALUE = _pywrapcp.Solver_ASSIGN_CENTER_VALUE 141 r""" Selects the first possible value which is the closest to the center of the domain of the selected variable. The center is defined as (min + max) / 2.""" 142 SPLIT_LOWER_HALF = _pywrapcp.Solver_SPLIT_LOWER_HALF 143 r""" Split the domain in two around the center, and choose the lower part first.""" 144 SPLIT_UPPER_HALF = _pywrapcp.Solver_SPLIT_UPPER_HALF 145 r""" Split the domain in two around the center, and choose the lower part first.""" 146 SEQUENCE_DEFAULT = _pywrapcp.Solver_SEQUENCE_DEFAULT 147 SEQUENCE_SIMPLE = _pywrapcp.Solver_SEQUENCE_SIMPLE 148 CHOOSE_MIN_SLACK_RANK_FORWARD = _pywrapcp.Solver_CHOOSE_MIN_SLACK_RANK_FORWARD 149 CHOOSE_RANDOM_RANK_FORWARD = _pywrapcp.Solver_CHOOSE_RANDOM_RANK_FORWARD 150 INTERVAL_DEFAULT = _pywrapcp.Solver_INTERVAL_DEFAULT 151 r""" The default is INTERVAL_SET_TIMES_FORWARD.""" 152 INTERVAL_SIMPLE = _pywrapcp.Solver_INTERVAL_SIMPLE 153 r""" The simple is INTERVAL_SET_TIMES_FORWARD.""" 154 INTERVAL_SET_TIMES_FORWARD = _pywrapcp.Solver_INTERVAL_SET_TIMES_FORWARD 155 r""" Selects the variable with the lowest starting time of all variables, and fixes its starting time to this lowest value.""" 156 INTERVAL_SET_TIMES_BACKWARD = _pywrapcp.Solver_INTERVAL_SET_TIMES_BACKWARD 157 r""" Selects the variable with the highest ending time of all variables, and fixes the ending time to this highest values.""" 158 TWOOPT = _pywrapcp.Solver_TWOOPT 159 r""" Operator which reverses a sub-chain of a path. It is called TwoOpt because it breaks two arcs on the path; resulting paths are called two-optimal. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> [3 -> 2] -> 4 -> 5 1 -> [4 -> 3 -> 2] -> 5 1 -> 2 -> [4 -> 3] -> 5""" 160 OROPT = _pywrapcp.Solver_OROPT 161 r""" Relocate: OROPT and RELOCATE. Operator which moves a sub-chain of a path to another position; the specified chain length is the fixed length of the chains being moved. When this length is 1, the operator simply moves a node to another position. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5, for a chain length of 2 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> 4 -> [2 -> 3] -> 5 1 -> [3 -> 4] -> 2 -> 5 Using Relocate with chain lengths of 1, 2 and 3 together is equivalent to the OrOpt operator on a path. The OrOpt operator is a limited version of 3Opt (breaks 3 arcs on a path).""" 162 RELOCATE = _pywrapcp.Solver_RELOCATE 163 r""" Relocate neighborhood with length of 1 (see OROPT comment).""" 164 EXCHANGE = _pywrapcp.Solver_EXCHANGE 165 r""" Operator which exchanges the positions of two nodes. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> [3] -> [2] -> 4 -> 5 1 -> [4] -> 3 -> [2] -> 5 1 -> 2 -> [4] -> [3] -> 5""" 166 CROSS = _pywrapcp.Solver_CROSS 167 r""" Operator which cross exchanges the starting chains of 2 paths, including exchanging the whole paths. First and last nodes are not moved. Possible neighbors for the paths 1 -> 2 -> 3 -> 4 -> 5 and 6 -> 7 -> 8 (where (1, 5) and (6, 8) are first and last nodes of the paths and can therefore not be moved): 1 -> [7] -> 3 -> 4 -> 5 6 -> [2] -> 8 1 -> [7] -> 4 -> 5 6 -> [2 -> 3] -> 8 1 -> [7] -> 5 6 -> [2 -> 3 -> 4] -> 8""" 168 MAKEACTIVE = _pywrapcp.Solver_MAKEACTIVE 169 r""" Operator which inserts an inactive node into a path. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 2 -> 3 -> 4 1 -> 2 -> [5] -> 3 -> 4 1 -> 2 -> 3 -> [5] -> 4""" 170 MAKEINACTIVE = _pywrapcp.Solver_MAKEINACTIVE 171 r""" Operator which makes path nodes inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are first and last nodes of the path) are: 1 -> 3 -> 4 with 2 inactive 1 -> 2 -> 4 with 3 inactive""" 172 MAKECHAININACTIVE = _pywrapcp.Solver_MAKECHAININACTIVE 173 r""" Operator which makes a "chain" of path nodes inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are first and last nodes of the path) are: 1 -> 3 -> 4 with 2 inactive 1 -> 2 -> 4 with 3 inactive 1 -> 4 with 2 and 3 inactive""" 174 SWAPACTIVE = _pywrapcp.Solver_SWAPACTIVE 175 r""" Operator which replaces an active node by an inactive one. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 3 -> 4 with 2 inactive 1 -> 2 -> [5] -> 4 with 3 inactive""" 176 EXTENDEDSWAPACTIVE = _pywrapcp.Solver_EXTENDEDSWAPACTIVE 177 r""" Operator which makes an inactive node active and an active one inactive. It is similar to SwapActiveOperator except that it tries to insert the inactive node in all possible positions instead of just the position of the node made inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 3 -> 4 with 2 inactive 1 -> 3 -> [5] -> 4 with 2 inactive 1 -> [5] -> 2 -> 4 with 3 inactive 1 -> 2 -> [5] -> 4 with 3 inactive""" 178 PATHLNS = _pywrapcp.Solver_PATHLNS 179 r""" Operator which relaxes two sub-chains of three consecutive arcs each. Each sub-chain is defined by a start node and the next three arcs. Those six arcs are relaxed to build a new neighbor. PATHLNS explores all possible pairs of starting nodes and so defines n^2 neighbors, n being the number of nodes. Note that the two sub-chains can be part of the same path; they even may overlap.""" 180 FULLPATHLNS = _pywrapcp.Solver_FULLPATHLNS 181 r""" Operator which relaxes one entire path and all inactive nodes, thus defining num_paths neighbors.""" 182 UNACTIVELNS = _pywrapcp.Solver_UNACTIVELNS 183 r""" Operator which relaxes all inactive nodes and one sub-chain of six consecutive arcs. That way the path can be improved by inserting inactive nodes or swapping arcs.""" 184 INCREMENT = _pywrapcp.Solver_INCREMENT 185 r""" Operator which defines one neighbor per variable. Each neighbor tries to increment by one the value of the corresponding variable. When a new solution is found the neighborhood is rebuilt from scratch, i.e., tries to increment values in the variable order. Consider for instance variables x and y. x is incremented one by one to its max, and when it is not possible to increment x anymore, y is incremented once. If this is a solution, then next neighbor tries to increment x.""" 186 DECREMENT = _pywrapcp.Solver_DECREMENT 187 r""" Operator which defines a neighborhood to decrement values. The behavior is the same as INCREMENT, except values are decremented instead of incremented.""" 188 SIMPLELNS = _pywrapcp.Solver_SIMPLELNS 189 r""" Operator which defines one neighbor per variable. Each neighbor relaxes one variable. When a new solution is found the neighborhood is rebuilt from scratch. Consider for instance variables x and y. First x is relaxed and the solver is looking for the best possible solution (with only x relaxed). Then y is relaxed, and the solver is looking for a new solution. If a new solution is found, then the next variable to be relaxed is x.""" 190 GE = _pywrapcp.Solver_GE 191 r""" Move is accepted when the current objective value >= objective.Min.""" 192 LE = _pywrapcp.Solver_LE 193 r""" Move is accepted when the current objective value <= objective.Max.""" 194 EQ = _pywrapcp.Solver_EQ 195 r""" Move is accepted when the current objective value is in the interval objective.Min .. objective.Max.""" 196 DELAYED_PRIORITY = _pywrapcp.Solver_DELAYED_PRIORITY 197 r""" DELAYED_PRIORITY is the lowest priority: Demons will be processed after VAR_PRIORITY and NORMAL_PRIORITY demons.""" 198 VAR_PRIORITY = _pywrapcp.Solver_VAR_PRIORITY 199 r""" VAR_PRIORITY is between DELAYED_PRIORITY and NORMAL_PRIORITY.""" 200 NORMAL_PRIORITY = _pywrapcp.Solver_NORMAL_PRIORITY 201 r""" NORMAL_PRIORITY is the highest priority: Demons will be processed first.""" 202 203 def __init__(self, *args): 204 _pywrapcp.Solver_swiginit(self, _pywrapcp.new_Solver(*args)) 205 206 self.__python_constraints = [] 207 208 209 210 __swig_destroy__ = _pywrapcp.delete_Solver 211 212 def Parameters(self) -> "operations_research::ConstraintSolverParameters": 213 r""" Stored Parameters.""" 214 return _pywrapcp.Solver_Parameters(self) 215 216 @staticmethod 217 def DefaultSolverParameters() -> "operations_research::ConstraintSolverParameters": 218 r""" Create a ConstraintSolverParameters proto with all the default values.""" 219 return _pywrapcp.Solver_DefaultSolverParameters() 220 221 def AddConstraint(self, c: "Constraint") -> "void": 222 r""" Adds the constraint 'c' to the model. After calling this method, and until there is a backtrack that undoes the addition, any assignment of variables to values must satisfy the given constraint in order to be considered feasible. There are two fairly different use cases: - the most common use case is modeling: the given constraint is really part of the problem that the user is trying to solve. In this use case, AddConstraint is called outside of search (i.e., with state() == OUTSIDE_SEARCH). Most users should only use AddConstraint in this way. In this case, the constraint will belong to the model forever: it cannot not be removed by backtracking. - a rarer use case is that 'c' is not a real constraint of the model. It may be a constraint generated by a branching decision (a constraint whose goal is to restrict the search space), a symmetry breaking constraint (a constraint that does restrict the search space, but in a way that cannot have an impact on the quality of the solutions in the subtree), or an inferred constraint that, while having no semantic value to the model (it does not restrict the set of solutions), is worth having because we believe it may strengthen the propagation. In these cases, it happens that the constraint is added during the search (i.e., with state() == IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is added during a search, it applies only to the subtree of the search tree rooted at the current node, and will be automatically removed by backtracking. This method does not take ownership of the constraint. If the constraint has been created by any factory method (Solver::MakeXXX), it will automatically be deleted. However, power users who implement their own constraints should do: solver.AddConstraint(solver.RevAlloc(new MyConstraint(...));""" 223 return _pywrapcp.Solver_AddConstraint(self, c) 224 225 def Solve(self, *args) -> "bool": 226 return _pywrapcp.Solver_Solve(self, *args) 227 228 def NewSearch(self, *args) -> "void": 229 return _pywrapcp.Solver_NewSearch(self, *args) 230 231 def NextSolution(self) -> "bool": 232 return _pywrapcp.Solver_NextSolution(self) 233 234 def RestartSearch(self) -> "void": 235 return _pywrapcp.Solver_RestartSearch(self) 236 237 def EndSearch(self) -> "void": 238 return _pywrapcp.Solver_EndSearch(self) 239 240 def SolveAndCommit(self, *args) -> "bool": 241 return _pywrapcp.Solver_SolveAndCommit(self, *args) 242 243 def CheckAssignment(self, solution: "Assignment") -> "bool": 244 r""" Checks whether the given assignment satisfies all relevant constraints.""" 245 return _pywrapcp.Solver_CheckAssignment(self, solution) 246 247 def CheckConstraint(self, ct: "Constraint") -> "bool": 248 r""" Checks whether adding this constraint will lead to an immediate failure. It will return false if the model is already inconsistent, or if adding the constraint makes it inconsistent.""" 249 return _pywrapcp.Solver_CheckConstraint(self, ct) 250 251 def Fail(self) -> "void": 252 r""" Abandon the current branch in the search tree. A backtrack will follow.""" 253 return _pywrapcp.Solver_Fail(self) 254 255 @staticmethod 256 def MemoryUsage() -> "int64_t": 257 r""" Current memory usage in bytes""" 258 return _pywrapcp.Solver_MemoryUsage() 259 260 def WallTime(self) -> "int64_t": 261 r""" DEPRECATED: Use Now() instead. Time elapsed, in ms since the creation of the solver.""" 262 return _pywrapcp.Solver_WallTime(self) 263 264 def Branches(self) -> "int64_t": 265 r""" The number of branches explored since the creation of the solver.""" 266 return _pywrapcp.Solver_Branches(self) 267 268 def Solutions(self) -> "int64_t": 269 r""" The number of solutions found since the start of the search.""" 270 return _pywrapcp.Solver_Solutions(self) 271 272 def Failures(self) -> "int64_t": 273 r""" The number of failures encountered since the creation of the solver.""" 274 return _pywrapcp.Solver_Failures(self) 275 276 def AcceptedNeighbors(self) -> "int64_t": 277 r""" The number of accepted neighbors.""" 278 return _pywrapcp.Solver_AcceptedNeighbors(self) 279 280 def Stamp(self) -> "uint64_t": 281 r""" The stamp indicates how many moves in the search tree we have performed. It is useful to detect if we need to update same lazy structures.""" 282 return _pywrapcp.Solver_Stamp(self) 283 284 def FailStamp(self) -> "uint64_t": 285 r""" The fail_stamp() is incremented after each backtrack.""" 286 return _pywrapcp.Solver_FailStamp(self) 287 288 def IntVar(self, *args) -> "operations_research::IntVar *": 289 r""" 290 *Overload 1:* 291 MakeIntVar will create the best range based int var for the bounds given. 292 293 | 294 295 *Overload 2:* 296 MakeIntVar will create a variable with the given sparse domain. 297 298 | 299 300 *Overload 3:* 301 MakeIntVar will create a variable with the given sparse domain. 302 303 | 304 305 *Overload 4:* 306 MakeIntVar will create the best range based int var for the bounds given. 307 308 | 309 310 *Overload 5:* 311 MakeIntVar will create a variable with the given sparse domain. 312 313 | 314 315 *Overload 6:* 316 MakeIntVar will create a variable with the given sparse domain. 317 """ 318 return _pywrapcp.Solver_IntVar(self, *args) 319 320 def BoolVar(self, *args) -> "operations_research::IntVar *": 321 r""" 322 *Overload 1:* 323 MakeBoolVar will create a variable with a {0, 1} domain. 324 325 | 326 327 *Overload 2:* 328 MakeBoolVar will create a variable with a {0, 1} domain. 329 """ 330 return _pywrapcp.Solver_BoolVar(self, *args) 331 332 def IntConst(self, *args) -> "operations_research::IntVar *": 333 r""" 334 *Overload 1:* 335 IntConst will create a constant expression. 336 337 | 338 339 *Overload 2:* 340 IntConst will create a constant expression. 341 """ 342 return _pywrapcp.Solver_IntConst(self, *args) 343 344 def Sum(self, vars: "std::vector< operations_research::IntVar * > const &") -> "operations_research::IntExpr *": 345 r""" sum of all vars.""" 346 return _pywrapcp.Solver_Sum(self, vars) 347 348 def ScalProd(self, *args) -> "operations_research::IntExpr *": 349 r""" 350 *Overload 1:* 351 scalar product 352 353 | 354 355 *Overload 2:* 356 scalar product 357 """ 358 return _pywrapcp.Solver_ScalProd(self, *args) 359 360 def MonotonicElement(self, values: "operations_research::Solver::IndexEvaluator1", increasing: "bool", index: "IntVar") -> "operations_research::IntExpr *": 361 r""" Function based element. The constraint takes ownership of the callback. The callback must be monotonic. It must be able to cope with any possible value in the domain of 'index' (potentially negative ones too). Furtermore, monotonicity is not checked. Thus giving a non-monotonic function, or specifying an incorrect increasing parameter will result in undefined behavior.""" 362 return _pywrapcp.Solver_MonotonicElement(self, values, increasing, index) 363 364 def Element(self, *args) -> "operations_research::IntExpr *": 365 r""" 366 *Overload 1:* 367 values[index] 368 369 | 370 371 *Overload 2:* 372 values[index] 373 374 | 375 376 *Overload 3:* 377 Function-based element. The constraint takes ownership of the callback. The callback must be able to cope with any possible value in the domain of 'index' (potentially negative ones too). 378 379 | 380 381 *Overload 4:* 382 2D version of function-based element expression, values(expr1, expr2). 383 384 | 385 386 *Overload 5:* 387 vars[expr] 388 """ 389 return _pywrapcp.Solver_Element(self, *args) 390 391 def IndexExpression(self, vars: "std::vector< operations_research::IntVar * > const &", value: "int64_t") -> "operations_research::IntExpr *": 392 r""" Returns the expression expr such that vars[expr] == value. It assumes that vars are all different.""" 393 return _pywrapcp.Solver_IndexExpression(self, vars, value) 394 395 def Min(self, *args) -> "operations_research::IntExpr *": 396 r""" 397 *Overload 1:* 398 std::min(vars) 399 400 | 401 402 *Overload 2:* 403 std::min (left, right) 404 405 | 406 407 *Overload 3:* 408 std::min(expr, value) 409 410 | 411 412 *Overload 4:* 413 std::min(expr, value) 414 """ 415 return _pywrapcp.Solver_Min(self, *args) 416 417 def Max(self, *args) -> "operations_research::IntExpr *": 418 r""" 419 *Overload 1:* 420 std::max(vars) 421 422 | 423 424 *Overload 2:* 425 std::max(left, right) 426 427 | 428 429 *Overload 3:* 430 std::max(expr, value) 431 432 | 433 434 *Overload 4:* 435 std::max(expr, value) 436 """ 437 return _pywrapcp.Solver_Max(self, *args) 438 439 def ConvexPiecewiseExpr(self, expr: "IntExpr", early_cost: "int64_t", early_date: "int64_t", late_date: "int64_t", late_cost: "int64_t") -> "operations_research::IntExpr *": 440 r""" Convex piecewise function.""" 441 return _pywrapcp.Solver_ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost) 442 443 def SemiContinuousExpr(self, expr: "IntExpr", fixed_charge: "int64_t", step: "int64_t") -> "operations_research::IntExpr *": 444 r""" Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b) a >= 0 and b >= 0""" 445 return _pywrapcp.Solver_SemiContinuousExpr(self, expr, fixed_charge, step) 446 447 def ConditionalExpression(self, condition: "IntVar", expr: "IntExpr", unperformed_value: "int64_t") -> "operations_research::IntExpr *": 448 r""" Conditional Expr condition ? expr : unperformed_value""" 449 return _pywrapcp.Solver_ConditionalExpression(self, condition, expr, unperformed_value) 450 451 def TrueConstraint(self) -> "operations_research::Constraint *": 452 r""" This constraint always succeeds.""" 453 return _pywrapcp.Solver_TrueConstraint(self) 454 455 def FalseConstraint(self, *args) -> "operations_research::Constraint *": 456 return _pywrapcp.Solver_FalseConstraint(self, *args) 457 458 def IsEqualCstCt(self, var: "IntExpr", value: "int64_t", boolvar: "IntVar") -> "operations_research::Constraint *": 459 r""" boolvar == (var == value)""" 460 return _pywrapcp.Solver_IsEqualCstCt(self, var, value, boolvar) 461 462 def IsEqualCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 463 r""" status var of (var == value)""" 464 return _pywrapcp.Solver_IsEqualCstVar(self, var, value) 465 466 def IsEqualCt(self, v1: "IntExpr", v2: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 467 r""" b == (v1 == v2)""" 468 return _pywrapcp.Solver_IsEqualCt(self, v1, v2, b) 469 470 def IsEqualVar(self, v1: "IntExpr", v2: "IntExpr") -> "operations_research::IntVar *": 471 r""" status var of (v1 == v2)""" 472 return _pywrapcp.Solver_IsEqualVar(self, v1, v2) 473 474 def IsDifferentCstCt(self, var: "IntExpr", value: "int64_t", boolvar: "IntVar") -> "operations_research::Constraint *": 475 r""" boolvar == (var != value)""" 476 return _pywrapcp.Solver_IsDifferentCstCt(self, var, value, boolvar) 477 478 def IsDifferentCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 479 r""" status var of (var != value)""" 480 return _pywrapcp.Solver_IsDifferentCstVar(self, var, value) 481 482 def IsDifferentVar(self, v1: "IntExpr", v2: "IntExpr") -> "operations_research::IntVar *": 483 r""" status var of (v1 != v2)""" 484 return _pywrapcp.Solver_IsDifferentVar(self, v1, v2) 485 486 def IsDifferentCt(self, v1: "IntExpr", v2: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 487 r""" b == (v1 != v2)""" 488 return _pywrapcp.Solver_IsDifferentCt(self, v1, v2, b) 489 490 def IsLessOrEqualCstCt(self, var: "IntExpr", value: "int64_t", boolvar: "IntVar") -> "operations_research::Constraint *": 491 r""" boolvar == (var <= value)""" 492 return _pywrapcp.Solver_IsLessOrEqualCstCt(self, var, value, boolvar) 493 494 def IsLessOrEqualCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 495 r""" status var of (var <= value)""" 496 return _pywrapcp.Solver_IsLessOrEqualCstVar(self, var, value) 497 498 def IsLessOrEqualVar(self, left: "IntExpr", right: "IntExpr") -> "operations_research::IntVar *": 499 r""" status var of (left <= right)""" 500 return _pywrapcp.Solver_IsLessOrEqualVar(self, left, right) 501 502 def IsLessOrEqualCt(self, left: "IntExpr", right: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 503 r""" b == (left <= right)""" 504 return _pywrapcp.Solver_IsLessOrEqualCt(self, left, right, b) 505 506 def IsGreaterOrEqualCstCt(self, var: "IntExpr", value: "int64_t", boolvar: "IntVar") -> "operations_research::Constraint *": 507 r""" boolvar == (var >= value)""" 508 return _pywrapcp.Solver_IsGreaterOrEqualCstCt(self, var, value, boolvar) 509 510 def IsGreaterOrEqualCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 511 r""" status var of (var >= value)""" 512 return _pywrapcp.Solver_IsGreaterOrEqualCstVar(self, var, value) 513 514 def IsGreaterOrEqualVar(self, left: "IntExpr", right: "IntExpr") -> "operations_research::IntVar *": 515 r""" status var of (left >= right)""" 516 return _pywrapcp.Solver_IsGreaterOrEqualVar(self, left, right) 517 518 def IsGreaterOrEqualCt(self, left: "IntExpr", right: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 519 r""" b == (left >= right)""" 520 return _pywrapcp.Solver_IsGreaterOrEqualCt(self, left, right, b) 521 522 def IsGreaterCstCt(self, v: "IntExpr", c: "int64_t", b: "IntVar") -> "operations_research::Constraint *": 523 r""" b == (v > c)""" 524 return _pywrapcp.Solver_IsGreaterCstCt(self, v, c, b) 525 526 def IsGreaterCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 527 r""" status var of (var > value)""" 528 return _pywrapcp.Solver_IsGreaterCstVar(self, var, value) 529 530 def IsGreaterVar(self, left: "IntExpr", right: "IntExpr") -> "operations_research::IntVar *": 531 r""" status var of (left > right)""" 532 return _pywrapcp.Solver_IsGreaterVar(self, left, right) 533 534 def IsGreaterCt(self, left: "IntExpr", right: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 535 r""" b == (left > right)""" 536 return _pywrapcp.Solver_IsGreaterCt(self, left, right, b) 537 538 def IsLessCstCt(self, v: "IntExpr", c: "int64_t", b: "IntVar") -> "operations_research::Constraint *": 539 r""" b == (v < c)""" 540 return _pywrapcp.Solver_IsLessCstCt(self, v, c, b) 541 542 def IsLessCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 543 r""" status var of (var < value)""" 544 return _pywrapcp.Solver_IsLessCstVar(self, var, value) 545 546 def IsLessVar(self, left: "IntExpr", right: "IntExpr") -> "operations_research::IntVar *": 547 r""" status var of (left < right)""" 548 return _pywrapcp.Solver_IsLessVar(self, left, right) 549 550 def IsLessCt(self, left: "IntExpr", right: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 551 r""" b == (left < right)""" 552 return _pywrapcp.Solver_IsLessCt(self, left, right, b) 553 554 def SumLessOrEqual(self, vars: "std::vector< operations_research::IntVar * > const &", cst: "int64_t") -> "operations_research::Constraint *": 555 r""" Variation on arrays.""" 556 return _pywrapcp.Solver_SumLessOrEqual(self, vars, cst) 557 558 def SumGreaterOrEqual(self, vars: "std::vector< operations_research::IntVar * > const &", cst: "int64_t") -> "operations_research::Constraint *": 559 return _pywrapcp.Solver_SumGreaterOrEqual(self, vars, cst) 560 561 def SumEquality(self, *args) -> "operations_research::Constraint *": 562 return _pywrapcp.Solver_SumEquality(self, *args) 563 564 def ScalProdEquality(self, *args) -> "operations_research::Constraint *": 565 return _pywrapcp.Solver_ScalProdEquality(self, *args) 566 567 def ScalProdGreaterOrEqual(self, *args) -> "operations_research::Constraint *": 568 return _pywrapcp.Solver_ScalProdGreaterOrEqual(self, *args) 569 570 def ScalProdLessOrEqual(self, *args) -> "operations_research::Constraint *": 571 return _pywrapcp.Solver_ScalProdLessOrEqual(self, *args) 572 573 def MinEquality(self, vars: "std::vector< operations_research::IntVar * > const &", min_var: "IntVar") -> "operations_research::Constraint *": 574 return _pywrapcp.Solver_MinEquality(self, vars, min_var) 575 576 def MaxEquality(self, vars: "std::vector< operations_research::IntVar * > const &", max_var: "IntVar") -> "operations_research::Constraint *": 577 return _pywrapcp.Solver_MaxEquality(self, vars, max_var) 578 579 def ElementEquality(self, *args) -> "operations_research::Constraint *": 580 return _pywrapcp.Solver_ElementEquality(self, *args) 581 582 def AbsEquality(self, var: "IntVar", abs_var: "IntVar") -> "operations_research::Constraint *": 583 r""" Creates the constraint abs(var) == abs_var.""" 584 return _pywrapcp.Solver_AbsEquality(self, var, abs_var) 585 586 def IndexOfConstraint(self, vars: "std::vector< operations_research::IntVar * > const &", index: "IntVar", target: "int64_t") -> "operations_research::Constraint *": 587 r""" This constraint is a special case of the element constraint with an array of integer variables, where the variables are all different and the index variable is constrained such that vars[index] == target.""" 588 return _pywrapcp.Solver_IndexOfConstraint(self, vars, index, target) 589 590 def ConstraintInitialPropagateCallback(self, ct: "Constraint") -> "operations_research::Demon *": 591 r""" This method is a specialized case of the MakeConstraintDemon method to call the InitiatePropagate of the constraint 'ct'.""" 592 return _pywrapcp.Solver_ConstraintInitialPropagateCallback(self, ct) 593 594 def DelayedConstraintInitialPropagateCallback(self, ct: "Constraint") -> "operations_research::Demon *": 595 r""" This method is a specialized case of the MakeConstraintDemon method to call the InitiatePropagate of the constraint 'ct' with low priority.""" 596 return _pywrapcp.Solver_DelayedConstraintInitialPropagateCallback(self, ct) 597 598 def ClosureDemon(self, closure: "operations_research::Solver::Closure") -> "operations_research::Demon *": 599 r""" Creates a demon from a closure.""" 600 return _pywrapcp.Solver_ClosureDemon(self, closure) 601 602 def BetweenCt(self, expr: "IntExpr", l: "int64_t", u: "int64_t") -> "operations_research::Constraint *": 603 r""" (l <= expr <= u)""" 604 return _pywrapcp.Solver_BetweenCt(self, expr, l, u) 605 606 def IsBetweenCt(self, expr: "IntExpr", l: "int64_t", u: "int64_t", b: "IntVar") -> "operations_research::Constraint *": 607 r""" b == (l <= expr <= u)""" 608 return _pywrapcp.Solver_IsBetweenCt(self, expr, l, u, b) 609 610 def IsBetweenVar(self, v: "IntExpr", l: "int64_t", u: "int64_t") -> "operations_research::IntVar *": 611 return _pywrapcp.Solver_IsBetweenVar(self, v, l, u) 612 613 def MemberCt(self, *args) -> "operations_research::Constraint *": 614 return _pywrapcp.Solver_MemberCt(self, *args) 615 616 def NotMemberCt(self, *args) -> "operations_research::Constraint *": 617 r""" 618 *Overload 1:* 619 expr not in set. 620 621 | 622 623 *Overload 2:* 624 expr should not be in the list of forbidden intervals [start[i]..end[i]]. 625 626 | 627 628 *Overload 3:* 629 expr should not be in the list of forbidden intervals [start[i]..end[i]]. 630 """ 631 return _pywrapcp.Solver_NotMemberCt(self, *args) 632 633 def IsMemberCt(self, *args) -> "operations_research::Constraint *": 634 return _pywrapcp.Solver_IsMemberCt(self, *args) 635 636 def IsMemberVar(self, *args) -> "operations_research::IntVar *": 637 return _pywrapcp.Solver_IsMemberVar(self, *args) 638 639 def Count(self, *args) -> "operations_research::Constraint *": 640 r""" 641 *Overload 1:* 642 |{i | vars[i] == value}| == max_count 643 644 | 645 646 *Overload 2:* 647 |{i | vars[i] == value}| == max_count 648 """ 649 return _pywrapcp.Solver_Count(self, *args) 650 651 def Distribute(self, *args) -> "operations_research::Constraint *": 652 r""" 653 *Overload 1:* 654 Aggregated version of count: |{i | v[i] == values[j]}| == cards[j] 655 656 | 657 658 *Overload 2:* 659 Aggregated version of count: |{i | v[i] == values[j]}| == cards[j] 660 661 | 662 663 *Overload 3:* 664 Aggregated version of count: |{i | v[i] == j}| == cards[j] 665 666 | 667 668 *Overload 4:* 669 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max 670 671 | 672 673 *Overload 5:* 674 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == j}| <= card_max[j] 675 676 | 677 678 *Overload 6:* 679 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == j}| <= card_max[j] 680 681 | 682 683 *Overload 7:* 684 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j] 685 686 | 687 688 *Overload 8:* 689 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j] 690 """ 691 return _pywrapcp.Solver_Distribute(self, *args) 692 693 def Deviation(self, vars: "std::vector< operations_research::IntVar * > const &", deviation_var: "IntVar", total_sum: "int64_t") -> "operations_research::Constraint *": 694 r""" Deviation constraint: sum_i |n * vars[i] - total_sum| <= deviation_var and sum_i vars[i] == total_sum n = #vars""" 695 return _pywrapcp.Solver_Deviation(self, vars, deviation_var, total_sum) 696 697 def AllDifferent(self, *args) -> "operations_research::Constraint *": 698 r""" 699 *Overload 1:* 700 All variables are pairwise different. This corresponds to the stronger version of the propagation algorithm. 701 702 | 703 704 *Overload 2:* 705 All variables are pairwise different. If 'stronger_propagation' is true, stronger, and potentially slower propagation will occur. This API will be deprecated in the future. 706 """ 707 return _pywrapcp.Solver_AllDifferent(self, *args) 708 709 def AllDifferentExcept(self, vars: "std::vector< operations_research::IntVar * > const &", escape_value: "int64_t") -> "operations_research::Constraint *": 710 r""" All variables are pairwise different, unless they are assigned to the escape value.""" 711 return _pywrapcp.Solver_AllDifferentExcept(self, vars, escape_value) 712 713 def SortingConstraint(self, vars: "std::vector< operations_research::IntVar * > const &", sorted: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 714 r""" Creates a constraint binding the arrays of variables "vars" and "sorted_vars": sorted_vars[0] must be equal to the minimum of all variables in vars, and so on: the value of sorted_vars[i] must be equal to the i-th value of variables invars. This constraint propagates in both directions: from "vars" to "sorted_vars" and vice-versa. Behind the scenes, this constraint maintains that: - sorted is always increasing. - whatever the values of vars, there exists a permutation that injects its values into the sorted variables. For more info, please have a look at: https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf""" 715 return _pywrapcp.Solver_SortingConstraint(self, vars, sorted) 716 717 def LexicalLess(self, left: "std::vector< operations_research::IntVar * > const &", right: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 718 r""" Creates a constraint that enforces that left is lexicographically less than right.""" 719 return _pywrapcp.Solver_LexicalLess(self, left, right) 720 721 def LexicalLessOrEqual(self, left: "std::vector< operations_research::IntVar * > const &", right: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 722 r""" Creates a constraint that enforces that left is lexicographically less than or equal to right.""" 723 return _pywrapcp.Solver_LexicalLessOrEqual(self, left, right) 724 725 def InversePermutationConstraint(self, left: "std::vector< operations_research::IntVar * > const &", right: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 726 r""" Creates a constraint that enforces that 'left' and 'right' both represent permutations of [0..left.size()-1], and that 'right' is the inverse permutation of 'left', i.e. for all i in [0..left.size()-1], right[left[i]] = i.""" 727 return _pywrapcp.Solver_InversePermutationConstraint(self, left, right) 728 729 def NullIntersect(self, first_vars: "std::vector< operations_research::IntVar * > const &", second_vars: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 730 r""" Creates a constraint that states that all variables in the first vector are different from all variables in the second group. Thus the set of values in the first vector does not intersect with the set of values in the second vector.""" 731 return _pywrapcp.Solver_NullIntersect(self, first_vars, second_vars) 732 733 def NullIntersectExcept(self, first_vars: "std::vector< operations_research::IntVar * > const &", second_vars: "std::vector< operations_research::IntVar * > const &", escape_value: "int64_t") -> "operations_research::Constraint *": 734 r""" Creates a constraint that states that all variables in the first vector are different from all variables from the second group, unless they are assigned to the escape value. Thus the set of values in the first vector minus the escape value does not intersect with the set of values in the second vector.""" 735 return _pywrapcp.Solver_NullIntersectExcept(self, first_vars, second_vars, escape_value) 736 737 def Circuit(self, nexts: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 738 r""" Force the "nexts" variable to create a complete Hamiltonian path.""" 739 return _pywrapcp.Solver_Circuit(self, nexts) 740 741 def SubCircuit(self, nexts: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 742 r""" Force the "nexts" variable to create a complete Hamiltonian path for those that do not loop upon themselves.""" 743 return _pywrapcp.Solver_SubCircuit(self, nexts) 744 745 def DelayedPathCumul(self, nexts: "std::vector< operations_research::IntVar * > const &", active: "std::vector< operations_research::IntVar * > const &", cumuls: "std::vector< operations_research::IntVar * > const &", transits: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 746 r""" Delayed version of the same constraint: propagation on the nexts variables is delayed until all constraints have propagated.""" 747 return _pywrapcp.Solver_DelayedPathCumul(self, nexts, active, cumuls, transits) 748 749 def PathCumul(self, *args) -> "operations_research::Constraint *": 750 r""" 751 *Overload 1:* 752 Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transits[i]. Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. 753 754 | 755 756 *Overload 2:* 757 Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]). Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. Ownership of transit_evaluator is taken and it must be a repeatable callback. 758 759 | 760 761 *Overload 3:* 762 Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i]. Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. Ownership of transit_evaluator is taken and it must be a repeatable callback. 763 """ 764 return _pywrapcp.Solver_PathCumul(self, *args) 765 766 def AllowedAssignments(self, *args) -> "operations_research::Constraint *": 767 r""" 768 *Overload 1:* 769 This method creates a constraint where the graph of the relation between the variables is given in extension. There are 'arity' variables involved in the relation and the graph is given by a integer tuple set. 770 771 | 772 773 *Overload 2:* 774 Compatibility layer for Python API. 775 """ 776 return _pywrapcp.Solver_AllowedAssignments(self, *args) 777 778 def TransitionConstraint(self, *args) -> "operations_research::Constraint *": 779 return _pywrapcp.Solver_TransitionConstraint(self, *args) 780 781 def NonOverlappingBoxesConstraint(self, *args) -> "operations_research::Constraint *": 782 return _pywrapcp.Solver_NonOverlappingBoxesConstraint(self, *args) 783 784 def Pack(self, vars: "std::vector< operations_research::IntVar * > const &", number_of_bins: "int") -> "operations_research::Pack *": 785 r""" This constraint packs all variables onto 'number_of_bins' variables. For any given variable, a value of 'number_of_bins' indicates that the variable is not assigned to any bin. Dimensions, i.e., cumulative constraints on this packing, can be added directly from the pack class.""" 786 return _pywrapcp.Solver_Pack(self, vars, number_of_bins) 787 788 def FixedDurationIntervalVar(self, *args) -> "operations_research::IntervalVar *": 789 r""" 790 *Overload 1:* 791 Creates an interval var with a fixed duration. The duration must be greater than 0. If optional is true, then the interval can be performed or unperformed. If optional is false, then the interval is always performed. 792 793 | 794 795 *Overload 2:* 796 Creates a performed interval var with a fixed duration. The duration must be greater than 0. 797 798 | 799 800 *Overload 3:* 801 Creates an interval var with a fixed duration, and performed_variable. The duration must be greater than 0. 802 """ 803 return _pywrapcp.Solver_FixedDurationIntervalVar(self, *args) 804 805 def FixedInterval(self, start: "int64_t", duration: "int64_t", name: "std::string const &") -> "operations_research::IntervalVar *": 806 r""" Creates a fixed and performed interval.""" 807 return _pywrapcp.Solver_FixedInterval(self, start, duration, name) 808 809 def IntervalVar(self, start_min: "int64_t", start_max: "int64_t", duration_min: "int64_t", duration_max: "int64_t", end_min: "int64_t", end_max: "int64_t", optional: "bool", name: "std::string const &") -> "operations_research::IntervalVar *": 810 r""" Creates an interval var by specifying the bounds on start, duration, and end.""" 811 return _pywrapcp.Solver_IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name) 812 813 def MirrorInterval(self, interval_var: "IntervalVar") -> "operations_research::IntervalVar *": 814 r""" Creates an interval var that is the mirror image of the given one, that is, the interval var obtained by reversing the axis.""" 815 return _pywrapcp.Solver_MirrorInterval(self, interval_var) 816 817 def FixedDurationStartSyncedOnStartIntervalVar(self, interval_var: "IntervalVar", duration: "int64_t", offset: "int64_t") -> "operations_research::IntervalVar *": 818 r""" Creates an interval var with a fixed duration whose start is synchronized with the start of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.""" 819 return _pywrapcp.Solver_FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset) 820 821 def FixedDurationStartSyncedOnEndIntervalVar(self, interval_var: "IntervalVar", duration: "int64_t", offset: "int64_t") -> "operations_research::IntervalVar *": 822 r""" Creates an interval var with a fixed duration whose start is synchronized with the end of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.""" 823 return _pywrapcp.Solver_FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset) 824 825 def FixedDurationEndSyncedOnStartIntervalVar(self, interval_var: "IntervalVar", duration: "int64_t", offset: "int64_t") -> "operations_research::IntervalVar *": 826 r""" Creates an interval var with a fixed duration whose end is synchronized with the start of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.""" 827 return _pywrapcp.Solver_FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset) 828 829 def FixedDurationEndSyncedOnEndIntervalVar(self, interval_var: "IntervalVar", duration: "int64_t", offset: "int64_t") -> "operations_research::IntervalVar *": 830 r""" Creates an interval var with a fixed duration whose end is synchronized with the end of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.""" 831 return _pywrapcp.Solver_FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset) 832 833 def IntervalRelaxedMin(self, interval_var: "IntervalVar") -> "operations_research::IntervalVar *": 834 r""" Creates and returns an interval variable that wraps around the given one, relaxing the min start and end. Relaxing means making unbounded when optional. If the variable is non-optional, this method returns interval_var. More precisely, such an interval variable behaves as follows: * When the underlying must be performed, the returned interval variable behaves exactly as the underlying; * When the underlying may or may not be performed, the returned interval variable behaves like the underlying, except that it is unbounded on the min side; * When the underlying cannot be performed, the returned interval variable is of duration 0 and must be performed in an interval unbounded on both sides. This is very useful to implement propagators that may only modify the start max or end max.""" 835 return _pywrapcp.Solver_IntervalRelaxedMin(self, interval_var) 836 837 def IntervalRelaxedMax(self, interval_var: "IntervalVar") -> "operations_research::IntervalVar *": 838 r""" Creates and returns an interval variable that wraps around the given one, relaxing the max start and end. Relaxing means making unbounded when optional. If the variable is non optional, this method returns interval_var. More precisely, such an interval variable behaves as follows: * When the underlying must be performed, the returned interval variable behaves exactly as the underlying; * When the underlying may or may not be performed, the returned interval variable behaves like the underlying, except that it is unbounded on the max side; * When the underlying cannot be performed, the returned interval variable is of duration 0 and must be performed in an interval unbounded on both sides. This is very useful for implementing propagators that may only modify the start min or end min.""" 839 return _pywrapcp.Solver_IntervalRelaxedMax(self, interval_var) 840 841 def TemporalDisjunction(self, *args) -> "operations_research::Constraint *": 842 r""" 843 *Overload 1:* 844 This constraint implements a temporal disjunction between two interval vars t1 and t2. 'alt' indicates which alternative was chosen (alt == 0 is equivalent to t1 before t2). 845 846 | 847 848 *Overload 2:* 849 This constraint implements a temporal disjunction between two interval vars. 850 """ 851 return _pywrapcp.Solver_TemporalDisjunction(self, *args) 852 853 def DisjunctiveConstraint(self, intervals: "std::vector< operations_research::IntervalVar * > const &", name: "std::string const &") -> "operations_research::DisjunctiveConstraint *": 854 r""" This constraint forces all interval vars into an non-overlapping sequence. Intervals with zero duration can be scheduled anywhere.""" 855 return _pywrapcp.Solver_DisjunctiveConstraint(self, intervals, name) 856 857 def Cumulative(self, *args) -> "operations_research::Constraint *": 858 r""" 859 *Overload 1:* 860 This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint. 861 862 | 863 864 *Overload 2:* 865 This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint. 866 867 | 868 869 *Overload 3:* 870 This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint. 871 872 | 873 874 *Overload 4:* 875 This constraint enforces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint. 876 877 | 878 879 *Overload 5:* 880 This constraint enforces that, for any integer t, the sum of demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should be positive. 881 882 | 883 884 *Overload 6:* 885 This constraint enforces that, for any integer t, the sum of demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should be positive. 886 """ 887 return _pywrapcp.Solver_Cumulative(self, *args) 888 889 def Cover(self, vars: "std::vector< operations_research::IntervalVar * > const &", target_var: "IntervalVar") -> "operations_research::Constraint *": 890 r""" This constraint states that the target_var is the convex hull of the intervals. If none of the interval variables is performed, then the target var is unperformed too. Also, if the target variable is unperformed, then all the intervals variables are unperformed too.""" 891 return _pywrapcp.Solver_Cover(self, vars, target_var) 892 893 def Assignment(self, *args) -> "operations_research::Assignment *": 894 r""" 895 *Overload 1:* 896 This method creates an empty assignment. 897 898 | 899 900 *Overload 2:* 901 This method creates an assignment which is a copy of 'a'. 902 """ 903 return _pywrapcp.Solver_Assignment(self, *args) 904 905 def FirstSolutionCollector(self, *args) -> "operations_research::SolutionCollector *": 906 r""" 907 *Overload 1:* 908 Collect the first solution of the search. 909 910 | 911 912 *Overload 2:* 913 Collect the first solution of the search. The variables will need to be added later. 914 """ 915 return _pywrapcp.Solver_FirstSolutionCollector(self, *args) 916 917 def LastSolutionCollector(self, *args) -> "operations_research::SolutionCollector *": 918 r""" 919 *Overload 1:* 920 Collect the last solution of the search. 921 922 | 923 924 *Overload 2:* 925 Collect the last solution of the search. The variables will need to be added later. 926 """ 927 return _pywrapcp.Solver_LastSolutionCollector(self, *args) 928 929 def BestValueSolutionCollector(self, *args) -> "operations_research::SolutionCollector *": 930 r""" 931 *Overload 1:* 932 Collect the solution corresponding to the optimal value of the objective of 'assignment'; if 'assignment' does not have an objective no solution is collected. This collector only collects one solution corresponding to the best objective value (the first one found). 933 934 | 935 936 *Overload 2:* 937 Collect the solution corresponding to the optimal value of the objective of 'assignment'; if 'assignment' does not have an objective no solution is collected. This collector only collects one solution corresponding to the best objective value (the first one found). The variables will need to be added later. 938 """ 939 return _pywrapcp.Solver_BestValueSolutionCollector(self, *args) 940 941 def AllSolutionCollector(self, *args) -> "operations_research::SolutionCollector *": 942 r""" 943 *Overload 1:* 944 Collect all solutions of the search. 945 946 | 947 948 *Overload 2:* 949 Collect all solutions of the search. The variables will need to be added later. 950 """ 951 return _pywrapcp.Solver_AllSolutionCollector(self, *args) 952 953 def Minimize(self, v: "IntVar", step: "int64_t") -> "operations_research::OptimizeVar *": 954 r""" Creates a minimization objective.""" 955 return _pywrapcp.Solver_Minimize(self, v, step) 956 957 def Maximize(self, v: "IntVar", step: "int64_t") -> "operations_research::OptimizeVar *": 958 r""" Creates a maximization objective.""" 959 return _pywrapcp.Solver_Maximize(self, v, step) 960 961 def Optimize(self, maximize: "bool", v: "IntVar", step: "int64_t") -> "operations_research::OptimizeVar *": 962 r""" Creates a objective with a given sense (true = maximization).""" 963 return _pywrapcp.Solver_Optimize(self, maximize, v, step) 964 965 def WeightedMinimize(self, *args) -> "operations_research::OptimizeVar *": 966 r""" 967 *Overload 1:* 968 Creates a minimization weighted objective. The actual objective is scalar_prod(sub_objectives, weights). 969 970 | 971 972 *Overload 2:* 973 Creates a minimization weighted objective. The actual objective is scalar_prod(sub_objectives, weights). 974 """ 975 return _pywrapcp.Solver_WeightedMinimize(self, *args) 976 977 def WeightedMaximize(self, *args) -> "operations_research::OptimizeVar *": 978 r""" 979 *Overload 1:* 980 Creates a maximization weigthed objective. 981 982 | 983 984 *Overload 2:* 985 Creates a maximization weigthed objective. 986 """ 987 return _pywrapcp.Solver_WeightedMaximize(self, *args) 988 989 def WeightedOptimize(self, *args) -> "operations_research::OptimizeVar *": 990 r""" 991 *Overload 1:* 992 Creates a weighted objective with a given sense (true = maximization). 993 994 | 995 996 *Overload 2:* 997 Creates a weighted objective with a given sense (true = maximization). 998 """ 999 return _pywrapcp.Solver_WeightedOptimize(self, *args) 1000 1001 def TabuSearch(self, maximize: "bool", v: "IntVar", step: "int64_t", vars: "std::vector< operations_research::IntVar * > const &", keep_tenure: "int64_t", forbid_tenure: "int64_t", tabu_factor: "double") -> "operations_research::SearchMonitor *": 1002 r""" MetaHeuristics which try to get the search out of local optima. Creates a Tabu Search monitor. In the context of local search the behavior is similar to MakeOptimize(), creating an objective in a given sense. The behavior differs once a local optimum is reached: thereafter solutions which degrade the value of the objective are allowed if they are not "tabu". A solution is "tabu" if it doesn't respect the following rules: - improving the best solution found so far - variables in the "keep" list must keep their value, variables in the "forbid" list must not take the value they have in the list. Variables with new values enter the tabu lists after each new solution found and leave the lists after a given number of iterations (called tenure). Only the variables passed to the method can enter the lists. The tabu criterion is softened by the tabu factor which gives the number of "tabu" violations which is tolerated; a factor of 1 means no violations allowed; a factor of 0 means all violations are allowed.""" 1003 return _pywrapcp.Solver_TabuSearch(self, maximize, v, step, vars, keep_tenure, forbid_tenure, tabu_factor) 1004 1005 def SimulatedAnnealing(self, maximize: "bool", v: "IntVar", step: "int64_t", initial_temperature: "int64_t") -> "operations_research::SearchMonitor *": 1006 r""" Creates a Simulated Annealing monitor.""" 1007 return _pywrapcp.Solver_SimulatedAnnealing(self, maximize, v, step, initial_temperature) 1008 1009 def LubyRestart(self, scale_factor: "int") -> "operations_research::SearchMonitor *": 1010 r""" This search monitor will restart the search periodically. At the iteration n, it will restart after scale_factor * Luby(n) failures where Luby is the Luby Strategy (i.e. 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8...).""" 1011 return _pywrapcp.Solver_LubyRestart(self, scale_factor) 1012 1013 def ConstantRestart(self, frequency: "int") -> "operations_research::SearchMonitor *": 1014 r""" This search monitor will restart the search periodically after 'frequency' failures.""" 1015 return _pywrapcp.Solver_ConstantRestart(self, frequency) 1016 1017 def TimeLimit(self, *args) -> "operations_research::RegularLimit *": 1018 return _pywrapcp.Solver_TimeLimit(self, *args) 1019 1020 def BranchesLimit(self, branches: "int64_t") -> "operations_research::RegularLimit *": 1021 r""" Creates a search limit that constrains the number of branches explored in the search tree.""" 1022 return _pywrapcp.Solver_BranchesLimit(self, branches) 1023 1024 def FailuresLimit(self, failures: "int64_t") -> "operations_research::RegularLimit *": 1025 r""" Creates a search limit that constrains the number of failures that can happen when exploring the search tree.""" 1026 return _pywrapcp.Solver_FailuresLimit(self, failures) 1027 1028 def SolutionsLimit(self, solutions: "int64_t") -> "operations_research::RegularLimit *": 1029 r""" Creates a search limit that constrains the number of solutions found during the search.""" 1030 return _pywrapcp.Solver_SolutionsLimit(self, solutions) 1031 1032 def Limit(self, *args) -> "operations_research::SearchLimit *": 1033 r""" 1034 *Overload 1:* 1035 Limits the search with the 'time', 'branches', 'failures' and 'solutions' limits. 'smart_time_check' reduces the calls to the wall 1036 1037 | 1038 1039 *Overload 2:* 1040 Creates a search limit from its protobuf description 1041 1042 | 1043 1044 *Overload 3:* 1045 Creates a search limit that is reached when either of the underlying limit is reached. That is, the returned limit is more stringent than both argument limits. 1046 """ 1047 return _pywrapcp.Solver_Limit(self, *args) 1048 1049 def CustomLimit(self, limiter: "std::function< bool () >") -> "operations_research::SearchLimit *": 1050 r""" Callback-based search limit. Search stops when limiter returns true; if this happens at a leaf the corresponding solution will be rejected.""" 1051 return _pywrapcp.Solver_CustomLimit(self, limiter) 1052 1053 def SearchLog(self, *args) -> "operations_research::SearchMonitor *": 1054 return _pywrapcp.Solver_SearchLog(self, *args) 1055 1056 def SearchTrace(self, prefix: "std::string const &") -> "operations_research::SearchMonitor *": 1057 r""" Creates a search monitor that will trace precisely the behavior of the search. Use this only for low level debugging.""" 1058 return _pywrapcp.Solver_SearchTrace(self, prefix) 1059 1060 def PrintModelVisitor(self) -> "operations_research::ModelVisitor *": 1061 r""" Prints the model.""" 1062 return _pywrapcp.Solver_PrintModelVisitor(self) 1063 1064 def StatisticsModelVisitor(self) -> "operations_research::ModelVisitor *": 1065 r""" Displays some nice statistics on the model.""" 1066 return _pywrapcp.Solver_StatisticsModelVisitor(self) 1067 1068 def AssignVariableValue(self, var: "IntVar", val: "int64_t") -> "operations_research::Decision *": 1069 r""" Decisions.""" 1070 return _pywrapcp.Solver_AssignVariableValue(self, var, val) 1071 1072 def VariableLessOrEqualValue(self, var: "IntVar", value: "int64_t") -> "operations_research::Decision *": 1073 return _pywrapcp.Solver_VariableLessOrEqualValue(self, var, value) 1074 1075 def VariableGreaterOrEqualValue(self, var: "IntVar", value: "int64_t") -> "operations_research::Decision *": 1076 return _pywrapcp.Solver_VariableGreaterOrEqualValue(self, var, value) 1077 1078 def SplitVariableDomain(self, var: "IntVar", val: "int64_t", start_with_lower_half: "bool") -> "operations_research::Decision *": 1079 return _pywrapcp.Solver_SplitVariableDomain(self, var, val, start_with_lower_half) 1080 1081 def AssignVariableValueOrFail(self, var: "IntVar", value: "int64_t") -> "operations_research::Decision *": 1082 return _pywrapcp.Solver_AssignVariableValueOrFail(self, var, value) 1083 1084 def AssignVariablesValues(self, vars: "std::vector< operations_research::IntVar * > const &", values: "std::vector< int64_t > const &") -> "operations_research::Decision *": 1085 return _pywrapcp.Solver_AssignVariablesValues(self, vars, values) 1086 1087 def FailDecision(self) -> "operations_research::Decision *": 1088 return _pywrapcp.Solver_FailDecision(self) 1089 1090 def Decision(self, apply: "operations_research::Solver::Action", refute: "operations_research::Solver::Action") -> "operations_research::Decision *": 1091 return _pywrapcp.Solver_Decision(self, apply, refute) 1092 1093 def Compose(self, dbs: "std::vector< operations_research::DecisionBuilder * > const &") -> "operations_research::DecisionBuilder *": 1094 return _pywrapcp.Solver_Compose(self, dbs) 1095 1096 def Try(self, dbs: "std::vector< operations_research::DecisionBuilder * > const &") -> "operations_research::DecisionBuilder *": 1097 return _pywrapcp.Solver_Try(self, dbs) 1098 1099 def DefaultPhase(self, *args) -> "operations_research::DecisionBuilder *": 1100 return _pywrapcp.Solver_DefaultPhase(self, *args) 1101 1102 def ScheduleOrPostpone(self, var: "IntervalVar", est: "int64_t", marker: "int64_t *const") -> "operations_research::Decision *": 1103 r""" Returns a decision that tries to schedule a task at a given time. On the Apply branch, it will set that interval var as performed and set its start to 'est'. On the Refute branch, it will just update the 'marker' to 'est' + 1. This decision is used in the INTERVAL_SET_TIMES_FORWARD strategy.""" 1104 return _pywrapcp.Solver_ScheduleOrPostpone(self, var, est, marker) 1105 1106 def ScheduleOrExpedite(self, var: "IntervalVar", est: "int64_t", marker: "int64_t *const") -> "operations_research::Decision *": 1107 r""" Returns a decision that tries to schedule a task at a given time. On the Apply branch, it will set that interval var as performed and set its end to 'est'. On the Refute branch, it will just update the 'marker' to 'est' - 1. This decision is used in the INTERVAL_SET_TIMES_BACKWARD strategy.""" 1108 return _pywrapcp.Solver_ScheduleOrExpedite(self, var, est, marker) 1109 1110 def RankFirstInterval(self, sequence: "SequenceVar", index: "int") -> "operations_research::Decision *": 1111 r""" Returns a decision that tries to rank first the ith interval var in the sequence variable.""" 1112 return _pywrapcp.Solver_RankFirstInterval(self, sequence, index) 1113 1114 def RankLastInterval(self, sequence: "SequenceVar", index: "int") -> "operations_research::Decision *": 1115 r""" Returns a decision that tries to rank last the ith interval var in the sequence variable.""" 1116 return _pywrapcp.Solver_RankLastInterval(self, sequence, index) 1117 1118 def Phase(self, *args) -> "operations_research::DecisionBuilder *": 1119 return _pywrapcp.Solver_Phase(self, *args) 1120 1121 def DecisionBuilderFromAssignment(self, assignment: "Assignment", db: "DecisionBuilder", vars: "std::vector< operations_research::IntVar * > const &") -> "operations_research::DecisionBuilder *": 1122 r""" Returns a decision builder for which the left-most leaf corresponds to assignment, the rest of the tree being explored using 'db'.""" 1123 return _pywrapcp.Solver_DecisionBuilderFromAssignment(self, assignment, db, vars) 1124 1125 def ConstraintAdder(self, ct: "Constraint") -> "operations_research::DecisionBuilder *": 1126 r""" Returns a decision builder that will add the given constraint to the model.""" 1127 return _pywrapcp.Solver_ConstraintAdder(self, ct) 1128 1129 def SolveOnce(self, db: "DecisionBuilder", monitors: "std::vector< operations_research::SearchMonitor * > const &") -> "operations_research::DecisionBuilder *": 1130 return _pywrapcp.Solver_SolveOnce(self, db, monitors) 1131 1132 def NestedOptimize(self, *args) -> "operations_research::DecisionBuilder *": 1133 return _pywrapcp.Solver_NestedOptimize(self, *args) 1134 1135 def RestoreAssignment(self, assignment: "Assignment") -> "operations_research::DecisionBuilder *": 1136 r""" Returns a DecisionBuilder which restores an Assignment (calls void Assignment::Restore())""" 1137 return _pywrapcp.Solver_RestoreAssignment(self, assignment) 1138 1139 def StoreAssignment(self, assignment: "Assignment") -> "operations_research::DecisionBuilder *": 1140 r""" Returns a DecisionBuilder which stores an Assignment (calls void Assignment::Store())""" 1141 return _pywrapcp.Solver_StoreAssignment(self, assignment) 1142 1143 def Operator(self, *args) -> "operations_research::LocalSearchOperator *": 1144 return _pywrapcp.Solver_Operator(self, *args) 1145 1146 def RandomLnsOperator(self, *args) -> "operations_research::LocalSearchOperator *": 1147 return _pywrapcp.Solver_RandomLnsOperator(self, *args) 1148 1149 def MoveTowardTargetOperator(self, *args) -> "operations_research::LocalSearchOperator *": 1150 r""" 1151 *Overload 1:* 1152 Creates a local search operator that tries to move the assignment of some variables toward a target. The target is given as an Assignment. This operator generates neighbors in which the only difference compared to the current state is that one variable that belongs to the target assignment is set to its target value. 1153 1154 | 1155 1156 *Overload 2:* 1157 Creates a local search operator that tries to move the assignment of some variables toward a target. The target is given either as two vectors: a vector of variables and a vector of associated target values. The two vectors should be of the same length. This operator generates neighbors in which the only difference compared to the current state is that one variable that belongs to the given vector is set to its target value. 1158 """ 1159 return _pywrapcp.Solver_MoveTowardTargetOperator(self, *args) 1160 1161 def ConcatenateOperators(self, *args) -> "operations_research::LocalSearchOperator *": 1162 return _pywrapcp.Solver_ConcatenateOperators(self, *args) 1163 1164 def RandomConcatenateOperators(self, *args) -> "operations_research::LocalSearchOperator *": 1165 r""" 1166 *Overload 1:* 1167 Randomized version of local search concatenator; calls a random operator at each call to MakeNextNeighbor(). 1168 1169 | 1170 1171 *Overload 2:* 1172 Randomized version of local search concatenator; calls a random operator at each call to MakeNextNeighbor(). The provided seed is used to initialize the random number generator. 1173 """ 1174 return _pywrapcp.Solver_RandomConcatenateOperators(self, *args) 1175 1176 def NeighborhoodLimit(self, op: "LocalSearchOperator", limit: "int64_t") -> "operations_research::LocalSearchOperator *": 1177 r""" Creates a local search operator that wraps another local search operator and limits the number of neighbors explored (i.e., calls to MakeNextNeighbor from the current solution (between two calls to Start()). When this limit is reached, MakeNextNeighbor() returns false. The counter is cleared when Start() is called.""" 1178 return _pywrapcp.Solver_NeighborhoodLimit(self, op, limit) 1179 1180 def LocalSearchPhase(self, *args) -> "operations_research::DecisionBuilder *": 1181 return _pywrapcp.Solver_LocalSearchPhase(self, *args) 1182 1183 def LocalSearchPhaseParameters(self, *args) -> "operations_research::LocalSearchPhaseParameters *": 1184 return _pywrapcp.Solver_LocalSearchPhaseParameters(self, *args) 1185 1186 def SearchDepth(self) -> "int": 1187 r""" Gets the search depth of the current active search. Returns -1 if there is no active search opened.""" 1188 return _pywrapcp.Solver_SearchDepth(self) 1189 1190 def SearchLeftDepth(self) -> "int": 1191 r""" Gets the search left depth of the current active search. Returns -1 if there is no active search opened.""" 1192 return _pywrapcp.Solver_SearchLeftDepth(self) 1193 1194 def SolveDepth(self) -> "int": 1195 r""" Gets the number of nested searches. It returns 0 outside search, 1 during the top level search, 2 or more in case of nested searches.""" 1196 return _pywrapcp.Solver_SolveDepth(self) 1197 1198 def Rand64(self, size: "int64_t") -> "int64_t": 1199 r""" Returns a random value between 0 and 'size' - 1;""" 1200 return _pywrapcp.Solver_Rand64(self, size) 1201 1202 def Rand32(self, size: "int32_t") -> "int32_t": 1203 r""" Returns a random value between 0 and 'size' - 1;""" 1204 return _pywrapcp.Solver_Rand32(self, size) 1205 1206 def ReSeed(self, seed: "int32_t") -> "void": 1207 r""" Reseed the solver random generator.""" 1208 return _pywrapcp.Solver_ReSeed(self, seed) 1209 1210 def LocalSearchProfile(self) -> "std::string": 1211 r""" Returns local search profiling information in a human readable format.""" 1212 return _pywrapcp.Solver_LocalSearchProfile(self) 1213 1214 def Constraints(self) -> "int": 1215 r""" Counts the number of constraints that have been added to the solver before the search.""" 1216 return _pywrapcp.Solver_Constraints(self) 1217 1218 def Accept(self, visitor: "operations_research::ModelVisitor *const") -> "void": 1219 r""" Accepts the given model visitor.""" 1220 return _pywrapcp.Solver_Accept(self, visitor) 1221 1222 def FinishCurrentSearch(self) -> "void": 1223 r""" Tells the solver to kill or restart the current search.""" 1224 return _pywrapcp.Solver_FinishCurrentSearch(self) 1225 1226 def RestartCurrentSearch(self) -> "void": 1227 return _pywrapcp.Solver_RestartCurrentSearch(self) 1228 1229 def ShouldFail(self) -> "void": 1230 r""" These methods are only useful for the SWIG wrappers, which need a way to externally cause the Solver to fail.""" 1231 return _pywrapcp.Solver_ShouldFail(self) 1232 1233 def __str__(self) -> "std::string": 1234 return _pywrapcp.Solver___str__(self) 1235 1236 def Add(self, ct): 1237 if isinstance(ct, PyConstraint): 1238 self.__python_constraints.append(ct) 1239 self.AddConstraint(ct) 1240 1241 1242 def TreeNoCycle(self, nexts: "std::vector< operations_research::IntVar * > const &", active: "std::vector< operations_research::IntVar * > const &", callback: "operations_research::Solver::IndexFilter1"=0) -> "operations_research::Constraint *": 1243 return _pywrapcp.Solver_TreeNoCycle(self, nexts, active, callback) 1244 1245 def SearchLogWithCallback(self, period: "int", callback: "std::function< std::string () >") -> "operations_research::SearchMonitor *": 1246 return _pywrapcp.Solver_SearchLogWithCallback(self, period, callback) 1247 1248 def ElementFunction(self, values: "std::function< int64_t (int64_t) >", index: "IntVar") -> "operations_research::IntExpr *": 1249 return _pywrapcp.Solver_ElementFunction(self, values, index) 1250 1251 def VarEvalValStrPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_evaluator: "std::function< int64_t (int64_t) >", val_str: "operations_research::Solver::IntValueStrategy") -> "operations_research::DecisionBuilder *": 1252 return _pywrapcp.Solver_VarEvalValStrPhase(self, vars, var_evaluator, val_str) 1253 1254 def VarStrValEvalPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_str: "operations_research::Solver::IntVarStrategy", val_eval: "operations_research::Solver::IndexEvaluator2") -> "operations_research::DecisionBuilder *": 1255 return _pywrapcp.Solver_VarStrValEvalPhase(self, vars, var_str, val_eval) 1256 1257 def VarEvalValEvalPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_eval: "std::function< int64_t (int64_t) >", val_eval: "operations_research::Solver::IndexEvaluator2") -> "operations_research::DecisionBuilder *": 1258 return _pywrapcp.Solver_VarEvalValEvalPhase(self, vars, var_eval, val_eval) 1259 1260 def VarStrValEvalTieBreakPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_str: "operations_research::Solver::IntVarStrategy", val_eval: "operations_research::Solver::IndexEvaluator2", tie_breaker: "std::function< int64_t (int64_t) >") -> "operations_research::DecisionBuilder *": 1261 return _pywrapcp.Solver_VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker) 1262 1263 def VarEvalValEvalTieBreakPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_eval: "std::function< int64_t (int64_t) >", val_eval: "operations_research::Solver::IndexEvaluator2", tie_breaker: "std::function< int64_t (int64_t) >") -> "operations_research::DecisionBuilder *": 1264 return _pywrapcp.Solver_VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker) 1265 1266 def EvalEvalStrPhase(self, vars: "std::vector< operations_research::IntVar * > const &", evaluator: "operations_research::Solver::IndexEvaluator2", str: "operations_research::Solver::EvaluatorStrategy") -> "operations_research::DecisionBuilder *": 1267 return _pywrapcp.Solver_EvalEvalStrPhase(self, vars, evaluator, str) 1268 1269 def EvalEvalStrTieBreakPhase(self, vars: "std::vector< operations_research::IntVar * > const &", evaluator: "operations_research::Solver::IndexEvaluator2", tie_breaker: "operations_research::Solver::IndexEvaluator1", str: "operations_research::Solver::EvaluatorStrategy") -> "operations_research::DecisionBuilder *": 1270 return _pywrapcp.Solver_EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str) 1271 1272 def GuidedLocalSearch(self, *args) -> "operations_research::SearchMonitor *": 1273 return _pywrapcp.Solver_GuidedLocalSearch(self, *args) 1274 1275 def SumObjectiveFilter(self, vars: "std::vector< operations_research::IntVar * > const &", values: "operations_research::Solver::IndexEvaluator2", filter_enum: "operations_research::Solver::LocalSearchFilterBound") -> "operations_research::LocalSearchFilter *": 1276 return _pywrapcp.Solver_SumObjectiveFilter(self, vars, values, filter_enum) 1277 1278# Register Solver in _pywrapcp: 1279_pywrapcp.Solver_swigregister(Solver) 1280 1281def Solver_DefaultSolverParameters() -> "operations_research::ConstraintSolverParameters": 1282 r""" Create a ConstraintSolverParameters proto with all the default values.""" 1283 return _pywrapcp.Solver_DefaultSolverParameters() 1284 1285def Solver_MemoryUsage() -> "int64_t": 1286 r""" Current memory usage in bytes""" 1287 return _pywrapcp.Solver_MemoryUsage() 1288 1289class BaseObject(object): 1290 r""" A BaseObject is the root of all reversibly allocated objects. A DebugString method and the associated << operator are implemented as a convenience.""" 1291 1292 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1293 1294 def __init__(self): 1295 if self.__class__ == BaseObject: 1296 _self = None 1297 else: 1298 _self = self 1299 _pywrapcp.BaseObject_swiginit(self, _pywrapcp.new_BaseObject(_self, )) 1300 __swig_destroy__ = _pywrapcp.delete_BaseObject 1301 1302 def DebugString(self) -> "std::string": 1303 return _pywrapcp.BaseObject_DebugString(self) 1304 1305 def __str__(self) -> "std::string": 1306 return _pywrapcp.BaseObject___str__(self) 1307 1308 def __repr__(self) -> "std::string": 1309 return _pywrapcp.BaseObject___repr__(self) 1310 def __disown__(self): 1311 self.this.disown() 1312 _pywrapcp.disown_BaseObject(self) 1313 return weakref.proxy(self) 1314 1315# Register BaseObject in _pywrapcp: 1316_pywrapcp.BaseObject_swigregister(BaseObject) 1317 1318class PropagationBaseObject(BaseObject): 1319 r""" NOLINT The PropagationBaseObject is a subclass of BaseObject that is also friend to the Solver class. It allows accessing methods useful when writing new constraints or new expressions.""" 1320 1321 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1322 __repr__ = _swig_repr 1323 1324 def __init__(self, s: "Solver"): 1325 if self.__class__ == PropagationBaseObject: 1326 _self = None 1327 else: 1328 _self = self 1329 _pywrapcp.PropagationBaseObject_swiginit(self, _pywrapcp.new_PropagationBaseObject(_self, s)) 1330 __swig_destroy__ = _pywrapcp.delete_PropagationBaseObject 1331 1332 def DebugString(self) -> "std::string": 1333 return _pywrapcp.PropagationBaseObject_DebugString(self) 1334 1335 def solver(self) -> "operations_research::Solver *": 1336 return _pywrapcp.PropagationBaseObject_solver(self) 1337 1338 def Name(self) -> "std::string": 1339 r""" Object naming.""" 1340 return _pywrapcp.PropagationBaseObject_Name(self) 1341 def __disown__(self): 1342 self.this.disown() 1343 _pywrapcp.disown_PropagationBaseObject(self) 1344 return weakref.proxy(self) 1345 1346# Register PropagationBaseObject in _pywrapcp: 1347_pywrapcp.PropagationBaseObject_swigregister(PropagationBaseObject) 1348 1349class Decision(BaseObject): 1350 r""" A Decision represents a choice point in the search tree. The two main methods are Apply() to go left, or Refute() to go right.""" 1351 1352 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1353 1354 def __init__(self): 1355 if self.__class__ == Decision: 1356 _self = None 1357 else: 1358 _self = self 1359 _pywrapcp.Decision_swiginit(self, _pywrapcp.new_Decision(_self, )) 1360 __swig_destroy__ = _pywrapcp.delete_Decision 1361 1362 def ApplyWrapper(self, s: "Solver") -> "void": 1363 r""" Apply will be called first when the decision is executed.""" 1364 return _pywrapcp.Decision_ApplyWrapper(self, s) 1365 1366 def RefuteWrapper(self, s: "Solver") -> "void": 1367 r""" Refute will be called after a backtrack.""" 1368 return _pywrapcp.Decision_RefuteWrapper(self, s) 1369 1370 def DebugString(self) -> "std::string": 1371 return _pywrapcp.Decision_DebugString(self) 1372 1373 def __repr__(self) -> "std::string": 1374 return _pywrapcp.Decision___repr__(self) 1375 1376 def __str__(self) -> "std::string": 1377 return _pywrapcp.Decision___str__(self) 1378 def __disown__(self): 1379 self.this.disown() 1380 _pywrapcp.disown_Decision(self) 1381 return weakref.proxy(self) 1382 1383# Register Decision in _pywrapcp: 1384_pywrapcp.Decision_swigregister(Decision) 1385 1386class DecisionBuilder(BaseObject): 1387 r""" A DecisionBuilder is responsible for creating the search tree. The important method is Next(), which returns the next decision to execute.""" 1388 1389 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1390 1391 def __init__(self): 1392 if self.__class__ == DecisionBuilder: 1393 _self = None 1394 else: 1395 _self = self 1396 _pywrapcp.DecisionBuilder_swiginit(self, _pywrapcp.new_DecisionBuilder(_self, )) 1397 __swig_destroy__ = _pywrapcp.delete_DecisionBuilder 1398 1399 def NextWrapper(self, s: "Solver") -> "operations_research::Decision *": 1400 r""" This is the main method of the decision builder class. It must return a decision (an instance of the class Decision). If it returns nullptr, this means that the decision builder has finished its work.""" 1401 return _pywrapcp.DecisionBuilder_NextWrapper(self, s) 1402 1403 def DebugString(self) -> "std::string": 1404 return _pywrapcp.DecisionBuilder_DebugString(self) 1405 1406 def __repr__(self) -> "std::string": 1407 return _pywrapcp.DecisionBuilder___repr__(self) 1408 1409 def __str__(self) -> "std::string": 1410 return _pywrapcp.DecisionBuilder___str__(self) 1411 def __disown__(self): 1412 self.this.disown() 1413 _pywrapcp.disown_DecisionBuilder(self) 1414 return weakref.proxy(self) 1415 1416# Register DecisionBuilder in _pywrapcp: 1417_pywrapcp.DecisionBuilder_swigregister(DecisionBuilder) 1418 1419class Demon(BaseObject): 1420 r""" A Demon is the base element of a propagation queue. It is the main object responsible for implementing the actual propagation of the constraint and pruning the inconsistent values in the domains of the variables. The main concept is that demons are listeners that are attached to the variables and listen to their modifications. There are two methods: - Run() is the actual method called when the demon is processed. - priority() returns its priority. Standard priorities are slow, normal or fast. "immediate" is reserved for variables and is treated separately.""" 1421 1422 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1423 __repr__ = _swig_repr 1424 1425 def __init__(self): 1426 r""" This indicates the priority of a demon. Immediate demons are treated separately and corresponds to variables.""" 1427 if self.__class__ == Demon: 1428 _self = None 1429 else: 1430 _self = self 1431 _pywrapcp.Demon_swiginit(self, _pywrapcp.new_Demon(_self, )) 1432 __swig_destroy__ = _pywrapcp.delete_Demon 1433 1434 def RunWrapper(self, s: "Solver") -> "void": 1435 r""" This is the main callback of the demon.""" 1436 return _pywrapcp.Demon_RunWrapper(self, s) 1437 1438 def Priority(self) -> "operations_research::Solver::DemonPriority": 1439 r""" This method returns the priority of the demon. Usually a demon is fast, slow or normal. Immediate demons are reserved for internal use to maintain variables.""" 1440 return _pywrapcp.Demon_Priority(self) 1441 1442 def DebugString(self) -> "std::string": 1443 return _pywrapcp.Demon_DebugString(self) 1444 1445 def Inhibit(self, s: "Solver") -> "void": 1446 r""" This method inhibits the demon in the search tree below the current position.""" 1447 return _pywrapcp.Demon_Inhibit(self, s) 1448 1449 def Desinhibit(self, s: "Solver") -> "void": 1450 r""" This method un-inhibits the demon that was previously inhibited.""" 1451 return _pywrapcp.Demon_Desinhibit(self, s) 1452 def __disown__(self): 1453 self.this.disown() 1454 _pywrapcp.disown_Demon(self) 1455 return weakref.proxy(self) 1456 1457# Register Demon in _pywrapcp: 1458_pywrapcp.Demon_swigregister(Demon) 1459 1460class Constraint(PropagationBaseObject): 1461 r""" A constraint is the main modeling object. It provides two methods: - Post() is responsible for creating the demons and attaching them to immediate demons(). - InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.""" 1462 1463 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1464 1465 def __init__(self, solver: "Solver"): 1466 if self.__class__ == Constraint: 1467 _self = None 1468 else: 1469 _self = self 1470 _pywrapcp.Constraint_swiginit(self, _pywrapcp.new_Constraint(_self, solver)) 1471 __swig_destroy__ = _pywrapcp.delete_Constraint 1472 1473 def Post(self) -> "void": 1474 r""" This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.""" 1475 return _pywrapcp.Constraint_Post(self) 1476 1477 def InitialPropagateWrapper(self) -> "void": 1478 r""" This method performs the initial propagation of the constraint. It is called just after the post.""" 1479 return _pywrapcp.Constraint_InitialPropagateWrapper(self) 1480 1481 def DebugString(self) -> "std::string": 1482 return _pywrapcp.Constraint_DebugString(self) 1483 1484 def Var(self) -> "operations_research::IntVar *": 1485 r""" Creates a Boolean variable representing the status of the constraint (false = constraint is violated, true = constraint is satisfied). It returns nullptr if the constraint does not support this API.""" 1486 return _pywrapcp.Constraint_Var(self) 1487 1488 def __repr__(self) -> "std::string": 1489 return _pywrapcp.Constraint___repr__(self) 1490 1491 def __str__(self) -> "std::string": 1492 return _pywrapcp.Constraint___str__(self) 1493 1494 def __add__(self, *args) -> "operations_research::IntExpr *": 1495 return _pywrapcp.Constraint___add__(self, *args) 1496 1497 def __radd__(self, v: "int64_t") -> "operations_research::IntExpr *": 1498 return _pywrapcp.Constraint___radd__(self, v) 1499 1500 def __sub__(self, *args) -> "operations_research::IntExpr *": 1501 return _pywrapcp.Constraint___sub__(self, *args) 1502 1503 def __rsub__(self, v: "int64_t") -> "operations_research::IntExpr *": 1504 return _pywrapcp.Constraint___rsub__(self, v) 1505 1506 def __mul__(self, *args) -> "operations_research::IntExpr *": 1507 return _pywrapcp.Constraint___mul__(self, *args) 1508 1509 def __rmul__(self, v: "int64_t") -> "operations_research::IntExpr *": 1510 return _pywrapcp.Constraint___rmul__(self, v) 1511 1512 def __floordiv__(self, v: "int64_t") -> "operations_research::IntExpr *": 1513 return _pywrapcp.Constraint___floordiv__(self, v) 1514 1515 def __neg__(self) -> "operations_research::IntExpr *": 1516 return _pywrapcp.Constraint___neg__(self) 1517 1518 def __abs__(self) -> "operations_research::IntExpr *": 1519 return _pywrapcp.Constraint___abs__(self) 1520 1521 def Square(self) -> "operations_research::IntExpr *": 1522 return _pywrapcp.Constraint_Square(self) 1523 1524 def __eq__(self, *args) -> "operations_research::Constraint *": 1525 return _pywrapcp.Constraint___eq__(self, *args) 1526 1527 def __ne__(self, *args) -> "operations_research::Constraint *": 1528 return _pywrapcp.Constraint___ne__(self, *args) 1529 1530 def __ge__(self, *args) -> "operations_research::Constraint *": 1531 return _pywrapcp.Constraint___ge__(self, *args) 1532 1533 def __gt__(self, *args) -> "operations_research::Constraint *": 1534 return _pywrapcp.Constraint___gt__(self, *args) 1535 1536 def __le__(self, *args) -> "operations_research::Constraint *": 1537 return _pywrapcp.Constraint___le__(self, *args) 1538 1539 def __lt__(self, *args) -> "operations_research::Constraint *": 1540 return _pywrapcp.Constraint___lt__(self, *args) 1541 1542 def MapTo(self, vars: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 1543 return _pywrapcp.Constraint_MapTo(self, vars) 1544 1545 def IndexOf(self, *args) -> "operations_research::IntExpr *": 1546 return _pywrapcp.Constraint_IndexOf(self, *args) 1547 def __disown__(self): 1548 self.this.disown() 1549 _pywrapcp.disown_Constraint(self) 1550 return weakref.proxy(self) 1551 1552# Register Constraint in _pywrapcp: 1553_pywrapcp.Constraint_swigregister(Constraint) 1554 1555class SearchMonitor(BaseObject): 1556 r""" A search monitor is a simple set of callbacks to monitor all search events""" 1557 1558 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1559 1560 def __init__(self, s: "Solver"): 1561 if self.__class__ == SearchMonitor: 1562 _self = None 1563 else: 1564 _self = self 1565 _pywrapcp.SearchMonitor_swiginit(self, _pywrapcp.new_SearchMonitor(_self, s)) 1566 __swig_destroy__ = _pywrapcp.delete_SearchMonitor 1567 1568 def EnterSearch(self) -> "void": 1569 r""" Beginning of the search.""" 1570 return _pywrapcp.SearchMonitor_EnterSearch(self) 1571 1572 def RestartSearch(self) -> "void": 1573 r""" Restart the search.""" 1574 return _pywrapcp.SearchMonitor_RestartSearch(self) 1575 1576 def ExitSearch(self) -> "void": 1577 r""" End of the search.""" 1578 return _pywrapcp.SearchMonitor_ExitSearch(self) 1579 1580 def BeginNextDecision(self, b: "DecisionBuilder") -> "void": 1581 r""" Before calling DecisionBuilder::Next.""" 1582 return _pywrapcp.SearchMonitor_BeginNextDecision(self, b) 1583 1584 def EndNextDecision(self, b: "DecisionBuilder", d: "Decision") -> "void": 1585 r""" After calling DecisionBuilder::Next, along with the returned decision.""" 1586 return _pywrapcp.SearchMonitor_EndNextDecision(self, b, d) 1587 1588 def ApplyDecision(self, d: "Decision") -> "void": 1589 r""" Before applying the decision.""" 1590 return _pywrapcp.SearchMonitor_ApplyDecision(self, d) 1591 1592 def RefuteDecision(self, d: "Decision") -> "void": 1593 r""" Before refuting the decision.""" 1594 return _pywrapcp.SearchMonitor_RefuteDecision(self, d) 1595 1596 def AfterDecision(self, d: "Decision", apply: "bool") -> "void": 1597 r""" Just after refuting or applying the decision, apply is true after Apply. This is called only if the Apply() or Refute() methods have not failed.""" 1598 return _pywrapcp.SearchMonitor_AfterDecision(self, d, apply) 1599 1600 def BeginFail(self) -> "void": 1601 r""" Just when the failure occurs.""" 1602 return _pywrapcp.SearchMonitor_BeginFail(self) 1603 1604 def EndFail(self) -> "void": 1605 r""" After completing the backtrack.""" 1606 return _pywrapcp.SearchMonitor_EndFail(self) 1607 1608 def BeginInitialPropagation(self) -> "void": 1609 r""" Before the initial propagation.""" 1610 return _pywrapcp.SearchMonitor_BeginInitialPropagation(self) 1611 1612 def EndInitialPropagation(self) -> "void": 1613 r""" After the initial propagation.""" 1614 return _pywrapcp.SearchMonitor_EndInitialPropagation(self) 1615 1616 def AcceptSolution(self) -> "bool": 1617 r""" This method is called when a solution is found. It asserts whether the solution is valid. A value of false indicates that the solution should be discarded.""" 1618 return _pywrapcp.SearchMonitor_AcceptSolution(self) 1619 1620 def AtSolution(self) -> "bool": 1621 r""" This method is called when a valid solution is found. If the return value is true, then search will resume after. If the result is false, then search will stop there.""" 1622 return _pywrapcp.SearchMonitor_AtSolution(self) 1623 1624 def NoMoreSolutions(self) -> "void": 1625 r""" When the search tree is finished.""" 1626 return _pywrapcp.SearchMonitor_NoMoreSolutions(self) 1627 1628 def LocalOptimum(self) -> "bool": 1629 r""" When a local optimum is reached. If 'true' is returned, the last solution is discarded and the search proceeds with the next one.""" 1630 return _pywrapcp.SearchMonitor_LocalOptimum(self) 1631 1632 def AcceptDelta(self, delta: "Assignment", deltadelta: "Assignment") -> "bool": 1633 return _pywrapcp.SearchMonitor_AcceptDelta(self, delta, deltadelta) 1634 1635 def AcceptNeighbor(self) -> "void": 1636 r""" After accepting a neighbor during local search.""" 1637 return _pywrapcp.SearchMonitor_AcceptNeighbor(self) 1638 1639 def solver(self) -> "operations_research::Solver *": 1640 return _pywrapcp.SearchMonitor_solver(self) 1641 1642 def __repr__(self) -> "std::string": 1643 return _pywrapcp.SearchMonitor___repr__(self) 1644 1645 def __str__(self) -> "std::string": 1646 return _pywrapcp.SearchMonitor___str__(self) 1647 def __disown__(self): 1648 self.this.disown() 1649 _pywrapcp.disown_SearchMonitor(self) 1650 return weakref.proxy(self) 1651 1652# Register SearchMonitor in _pywrapcp: 1653_pywrapcp.SearchMonitor_swigregister(SearchMonitor) 1654 1655class IntExpr(PropagationBaseObject): 1656 r""" The class IntExpr is the base of all integer expressions in constraint programming. It contains the basic protocol for an expression: - setting and modifying its bound - querying if it is bound - listening to events modifying its bounds - casting it into a variable (instance of IntVar)""" 1657 1658 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1659 1660 def __init__(self, *args, **kwargs): 1661 raise AttributeError("No constructor defined - class is abstract") 1662 1663 def Min(self) -> "int64_t": 1664 return _pywrapcp.IntExpr_Min(self) 1665 1666 def SetMin(self, m: "int64_t") -> "void": 1667 return _pywrapcp.IntExpr_SetMin(self, m) 1668 1669 def Max(self) -> "int64_t": 1670 return _pywrapcp.IntExpr_Max(self) 1671 1672 def SetMax(self, m: "int64_t") -> "void": 1673 return _pywrapcp.IntExpr_SetMax(self, m) 1674 1675 def SetRange(self, l: "int64_t", u: "int64_t") -> "void": 1676 r""" This method sets both the min and the max of the expression.""" 1677 return _pywrapcp.IntExpr_SetRange(self, l, u) 1678 1679 def SetValue(self, v: "int64_t") -> "void": 1680 r""" This method sets the value of the expression.""" 1681 return _pywrapcp.IntExpr_SetValue(self, v) 1682 1683 def Bound(self) -> "bool": 1684 r""" Returns true if the min and the max of the expression are equal.""" 1685 return _pywrapcp.IntExpr_Bound(self) 1686 1687 def IsVar(self) -> "bool": 1688 r""" Returns true if the expression is indeed a variable.""" 1689 return _pywrapcp.IntExpr_IsVar(self) 1690 1691 def Var(self) -> "operations_research::IntVar *": 1692 r""" Creates a variable from the expression.""" 1693 return _pywrapcp.IntExpr_Var(self) 1694 1695 def VarWithName(self, name: "std::string const &") -> "operations_research::IntVar *": 1696 r""" Creates a variable from the expression and set the name of the resulting var. If the expression is already a variable, then it will set the name of the expression, possibly overwriting it. This is just a shortcut to Var() followed by set_name().""" 1697 return _pywrapcp.IntExpr_VarWithName(self, name) 1698 1699 def WhenRange(self, *args) -> "void": 1700 r""" 1701 *Overload 1:* 1702 Attach a demon that will watch the min or the max of the expression. 1703 1704 | 1705 1706 *Overload 2:* 1707 Attach a demon that will watch the min or the max of the expression. 1708 """ 1709 return _pywrapcp.IntExpr_WhenRange(self, *args) 1710 1711 def __repr__(self) -> "std::string": 1712 return _pywrapcp.IntExpr___repr__(self) 1713 1714 def __str__(self) -> "std::string": 1715 return _pywrapcp.IntExpr___str__(self) 1716 1717 def __add__(self, *args) -> "operations_research::IntExpr *": 1718 return _pywrapcp.IntExpr___add__(self, *args) 1719 1720 def __radd__(self, v: "int64_t") -> "operations_research::IntExpr *": 1721 return _pywrapcp.IntExpr___radd__(self, v) 1722 1723 def __sub__(self, *args) -> "operations_research::IntExpr *": 1724 return _pywrapcp.IntExpr___sub__(self, *args) 1725 1726 def __rsub__(self, v: "int64_t") -> "operations_research::IntExpr *": 1727 return _pywrapcp.IntExpr___rsub__(self, v) 1728 1729 def __mul__(self, *args) -> "operations_research::IntExpr *": 1730 return _pywrapcp.IntExpr___mul__(self, *args) 1731 1732 def __rmul__(self, v: "int64_t") -> "operations_research::IntExpr *": 1733 return _pywrapcp.IntExpr___rmul__(self, v) 1734 1735 def __floordiv__(self, *args) -> "operations_research::IntExpr *": 1736 return _pywrapcp.IntExpr___floordiv__(self, *args) 1737 1738 def __mod__(self, *args) -> "operations_research::IntExpr *": 1739 return _pywrapcp.IntExpr___mod__(self, *args) 1740 1741 def __neg__(self) -> "operations_research::IntExpr *": 1742 return _pywrapcp.IntExpr___neg__(self) 1743 1744 def __abs__(self) -> "operations_research::IntExpr *": 1745 return _pywrapcp.IntExpr___abs__(self) 1746 1747 def Square(self) -> "operations_research::IntExpr *": 1748 return _pywrapcp.IntExpr_Square(self) 1749 1750 def __eq__(self, *args) -> "operations_research::Constraint *": 1751 return _pywrapcp.IntExpr___eq__(self, *args) 1752 1753 def __ne__(self, *args) -> "operations_research::Constraint *": 1754 return _pywrapcp.IntExpr___ne__(self, *args) 1755 1756 def __ge__(self, *args) -> "operations_research::Constraint *": 1757 return _pywrapcp.IntExpr___ge__(self, *args) 1758 1759 def __gt__(self, *args) -> "operations_research::Constraint *": 1760 return _pywrapcp.IntExpr___gt__(self, *args) 1761 1762 def __le__(self, *args) -> "operations_research::Constraint *": 1763 return _pywrapcp.IntExpr___le__(self, *args) 1764 1765 def __lt__(self, *args) -> "operations_research::Constraint *": 1766 return _pywrapcp.IntExpr___lt__(self, *args) 1767 1768 def MapTo(self, vars: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 1769 return _pywrapcp.IntExpr_MapTo(self, vars) 1770 1771 def IndexOf(self, *args) -> "operations_research::IntExpr *": 1772 return _pywrapcp.IntExpr_IndexOf(self, *args) 1773 1774 def IsMember(self, values: "std::vector< int64_t > const &") -> "operations_research::IntVar *": 1775 return _pywrapcp.IntExpr_IsMember(self, values) 1776 1777 def Member(self, values: "std::vector< int64_t > const &") -> "operations_research::Constraint *": 1778 return _pywrapcp.IntExpr_Member(self, values) 1779 1780 def NotMember(self, starts: "std::vector< int64_t > const &", ends: "std::vector< int64_t > const &") -> "operations_research::Constraint *": 1781 return _pywrapcp.IntExpr_NotMember(self, starts, ends) 1782 1783# Register IntExpr in _pywrapcp: 1784_pywrapcp.IntExpr_swigregister(IntExpr) 1785 1786class IntVarIterator(BaseObject): 1787 r""" The class Iterator has two direct subclasses. HoleIterators iterates over all holes, that is value removed between the current min and max of the variable since the last time the variable was processed in the queue. DomainIterators iterates over all elements of the variable domain. Both iterators are not robust to domain changes. Hole iterators can also report values outside the current min and max of the variable. HoleIterators should only be called from a demon attached to the variable that has created this iterator. IntVar* current_var; std::unique_ptr<IntVarIterator> it(current_var->MakeHoleIterator(false)); for (const int64_t hole : InitAndGetValues(it)) { /// use the hole }""" 1788 1789 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1790 1791 def __init__(self, *args, **kwargs): 1792 raise AttributeError("No constructor defined - class is abstract") 1793 __repr__ = _swig_repr 1794 1795 def Init(self) -> "void": 1796 r""" This method must be called before each loop.""" 1797 return _pywrapcp.IntVarIterator_Init(self) 1798 1799 def Ok(self) -> "bool": 1800 r""" This method indicates if we can call Value() or not.""" 1801 return _pywrapcp.IntVarIterator_Ok(self) 1802 1803 def Value(self) -> "int64_t": 1804 r""" This method returns the current value of the iterator.""" 1805 return _pywrapcp.IntVarIterator_Value(self) 1806 1807 def Next(self) -> "void": 1808 r""" This method moves the iterator to the next value.""" 1809 return _pywrapcp.IntVarIterator_Next(self) 1810 1811 def DebugString(self) -> "std::string": 1812 r""" Pretty Print.""" 1813 return _pywrapcp.IntVarIterator_DebugString(self) 1814 1815 def __iter__(self): 1816 self.Init() 1817 return self 1818 1819 def next(self): 1820 if self.Ok(): 1821 result = self.Value() 1822 self.Next() 1823 return result 1824 else: 1825 raise StopIteration() 1826 1827 def __next__(self): 1828 return self.next() 1829 1830 1831# Register IntVarIterator in _pywrapcp: 1832_pywrapcp.IntVarIterator_swigregister(IntVarIterator) 1833 1834class IntVar(IntExpr): 1835 r""" The class IntVar is a subset of IntExpr. In addition to the IntExpr protocol, it offers persistence, removing values from the domains, and a finer model for events.""" 1836 1837 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1838 1839 def __init__(self, *args, **kwargs): 1840 raise AttributeError("No constructor defined - class is abstract") 1841 1842 def IsVar(self) -> "bool": 1843 return _pywrapcp.IntVar_IsVar(self) 1844 1845 def Var(self) -> "operations_research::IntVar *": 1846 return _pywrapcp.IntVar_Var(self) 1847 1848 def Value(self) -> "int64_t": 1849 r""" This method returns the value of the variable. This method checks before that the variable is bound.""" 1850 return _pywrapcp.IntVar_Value(self) 1851 1852 def RemoveValue(self, v: "int64_t") -> "void": 1853 r""" This method removes the value 'v' from the domain of the variable.""" 1854 return _pywrapcp.IntVar_RemoveValue(self, v) 1855 1856 def RemoveInterval(self, l: "int64_t", u: "int64_t") -> "void": 1857 r""" This method removes the interval 'l' .. 'u' from the domain of the variable. It assumes that 'l' <= 'u'.""" 1858 return _pywrapcp.IntVar_RemoveInterval(self, l, u) 1859 1860 def RemoveValues(self, values: "std::vector< int64_t > const &") -> "void": 1861 r""" This method remove the values from the domain of the variable.""" 1862 return _pywrapcp.IntVar_RemoveValues(self, values) 1863 1864 def SetValues(self, values: "std::vector< int64_t > const &") -> "void": 1865 r""" This method intersects the current domain with the values in the array.""" 1866 return _pywrapcp.IntVar_SetValues(self, values) 1867 1868 def WhenBound(self, *args) -> "void": 1869 r""" 1870 *Overload 1:* 1871 This method attaches a demon that will be awakened when the variable is bound. 1872 1873 | 1874 1875 *Overload 2:* 1876 This method attaches a closure that will be awakened when the variable is bound. 1877 """ 1878 return _pywrapcp.IntVar_WhenBound(self, *args) 1879 1880 def WhenDomain(self, *args) -> "void": 1881 r""" 1882 *Overload 1:* 1883 This method attaches a demon that will watch any domain modification of the domain of the variable. 1884 1885 | 1886 1887 *Overload 2:* 1888 This method attaches a closure that will watch any domain modification of the domain of the variable. 1889 """ 1890 return _pywrapcp.IntVar_WhenDomain(self, *args) 1891 1892 def Size(self) -> "uint64_t": 1893 r""" This method returns the number of values in the domain of the variable.""" 1894 return _pywrapcp.IntVar_Size(self) 1895 1896 def Contains(self, v: "int64_t") -> "bool": 1897 r""" This method returns whether the value 'v' is in the domain of the variable.""" 1898 return _pywrapcp.IntVar_Contains(self, v) 1899 1900 def HoleIteratorAux(self, reversible: "bool") -> "operations_research::IntVarIterator *": 1901 r""" Creates a hole iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.""" 1902 return _pywrapcp.IntVar_HoleIteratorAux(self, reversible) 1903 1904 def DomainIteratorAux(self, reversible: "bool") -> "operations_research::IntVarIterator *": 1905 r""" Creates a domain iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.""" 1906 return _pywrapcp.IntVar_DomainIteratorAux(self, reversible) 1907 1908 def OldMin(self) -> "int64_t": 1909 r""" Returns the previous min.""" 1910 return _pywrapcp.IntVar_OldMin(self) 1911 1912 def OldMax(self) -> "int64_t": 1913 r""" Returns the previous max.""" 1914 return _pywrapcp.IntVar_OldMax(self) 1915 1916 def __repr__(self) -> "std::string": 1917 return _pywrapcp.IntVar___repr__(self) 1918 1919 def __str__(self) -> "std::string": 1920 return _pywrapcp.IntVar___str__(self) 1921 1922 def DomainIterator(self): 1923 return iter(self.DomainIteratorAux(False)) 1924 1925 def HoleIterator(self): 1926 return iter(self.HoleIteratorAux(False)) 1927 1928 1929# Register IntVar in _pywrapcp: 1930_pywrapcp.IntVar_swigregister(IntVar) 1931 1932class SolutionCollector(SearchMonitor): 1933 r""" This class is the root class of all solution collectors. It implements a basic query API to be used independently of the collector used.""" 1934 1935 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1936 1937 def __init__(self, *args, **kwargs): 1938 raise AttributeError("No constructor defined") 1939 __repr__ = _swig_repr 1940 1941 def DebugString(self) -> "std::string": 1942 return _pywrapcp.SolutionCollector_DebugString(self) 1943 1944 def Add(self, *args) -> "void": 1945 return _pywrapcp.SolutionCollector_Add(self, *args) 1946 1947 def AddObjective(self, objective: "IntVar") -> "void": 1948 return _pywrapcp.SolutionCollector_AddObjective(self, objective) 1949 1950 def EnterSearch(self) -> "void": 1951 r""" Beginning of the search.""" 1952 return _pywrapcp.SolutionCollector_EnterSearch(self) 1953 1954 def SolutionCount(self) -> "int": 1955 r""" Returns how many solutions were stored during the search.""" 1956 return _pywrapcp.SolutionCollector_SolutionCount(self) 1957 1958 def Solution(self, n: "int") -> "operations_research::Assignment *": 1959 r""" Returns the nth solution.""" 1960 return _pywrapcp.SolutionCollector_Solution(self, n) 1961 1962 def WallTime(self, n: "int") -> "int64_t": 1963 r""" Returns the wall time in ms for the nth solution.""" 1964 return _pywrapcp.SolutionCollector_WallTime(self, n) 1965 1966 def Branches(self, n: "int") -> "int64_t": 1967 r""" Returns the number of branches when the nth solution was found.""" 1968 return _pywrapcp.SolutionCollector_Branches(self, n) 1969 1970 def Failures(self, n: "int") -> "int64_t": 1971 r""" Returns the number of failures encountered at the time of the nth solution.""" 1972 return _pywrapcp.SolutionCollector_Failures(self, n) 1973 1974 def ObjectiveValue(self, n: "int") -> "int64_t": 1975 r""" Returns the objective value of the nth solution.""" 1976 return _pywrapcp.SolutionCollector_ObjectiveValue(self, n) 1977 1978 def Value(self, n: "int", var: "IntVar") -> "int64_t": 1979 r""" This is a shortcut to get the Value of 'var' in the nth solution.""" 1980 return _pywrapcp.SolutionCollector_Value(self, n, var) 1981 1982 def StartValue(self, n: "int", var: "IntervalVar") -> "int64_t": 1983 r""" This is a shortcut to get the StartValue of 'var' in the nth solution.""" 1984 return _pywrapcp.SolutionCollector_StartValue(self, n, var) 1985 1986 def EndValue(self, n: "int", var: "IntervalVar") -> "int64_t": 1987 r""" This is a shortcut to get the EndValue of 'var' in the nth solution.""" 1988 return _pywrapcp.SolutionCollector_EndValue(self, n, var) 1989 1990 def DurationValue(self, n: "int", var: "IntervalVar") -> "int64_t": 1991 r""" This is a shortcut to get the DurationValue of 'var' in the nth solution.""" 1992 return _pywrapcp.SolutionCollector_DurationValue(self, n, var) 1993 1994 def PerformedValue(self, n: "int", var: "IntervalVar") -> "int64_t": 1995 r""" This is a shortcut to get the PerformedValue of 'var' in the nth solution.""" 1996 return _pywrapcp.SolutionCollector_PerformedValue(self, n, var) 1997 1998 def ForwardSequence(self, n: "int", var: "SequenceVar") -> "std::vector< int > const &": 1999 r""" This is a shortcut to get the ForwardSequence of 'var' in the nth solution. The forward sequence is the list of ranked interval variables starting from the start of the sequence.""" 2000 return _pywrapcp.SolutionCollector_ForwardSequence(self, n, var) 2001 2002 def BackwardSequence(self, n: "int", var: "SequenceVar") -> "std::vector< int > const &": 2003 r""" This is a shortcut to get the BackwardSequence of 'var' in the nth solution. The backward sequence is the list of ranked interval variables starting from the end of the sequence.""" 2004 return _pywrapcp.SolutionCollector_BackwardSequence(self, n, var) 2005 2006 def Unperformed(self, n: "int", var: "SequenceVar") -> "std::vector< int > const &": 2007 r""" This is a shortcut to get the list of unperformed of 'var' in the nth solution.""" 2008 return _pywrapcp.SolutionCollector_Unperformed(self, n, var) 2009 2010# Register SolutionCollector in _pywrapcp: 2011_pywrapcp.SolutionCollector_swigregister(SolutionCollector) 2012 2013class OptimizeVar(SearchMonitor): 2014 r""" This class encapsulates an objective. It requires the direction (minimize or maximize), the variable to optimize, and the improvement step.""" 2015 2016 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2017 2018 def __init__(self, *args, **kwargs): 2019 raise AttributeError("No constructor defined") 2020 __repr__ = _swig_repr 2021 2022 def Best(self) -> "int64_t": 2023 r""" Returns the best value found during search.""" 2024 return _pywrapcp.OptimizeVar_Best(self) 2025 2026 def Var(self) -> "operations_research::IntVar *": 2027 r""" Returns the variable that is optimized.""" 2028 return _pywrapcp.OptimizeVar_Var(self) 2029 2030 def AcceptDelta(self, delta: "Assignment", deltadelta: "Assignment") -> "bool": 2031 r""" Internal methods.""" 2032 return _pywrapcp.OptimizeVar_AcceptDelta(self, delta, deltadelta) 2033 2034 def EnterSearch(self) -> "void": 2035 return _pywrapcp.OptimizeVar_EnterSearch(self) 2036 2037 def BeginNextDecision(self, db: "DecisionBuilder") -> "void": 2038 return _pywrapcp.OptimizeVar_BeginNextDecision(self, db) 2039 2040 def RefuteDecision(self, d: "Decision") -> "void": 2041 return _pywrapcp.OptimizeVar_RefuteDecision(self, d) 2042 2043 def AtSolution(self) -> "bool": 2044 return _pywrapcp.OptimizeVar_AtSolution(self) 2045 2046 def AcceptSolution(self) -> "bool": 2047 return _pywrapcp.OptimizeVar_AcceptSolution(self) 2048 2049 def DebugString(self) -> "std::string": 2050 return _pywrapcp.OptimizeVar_DebugString(self) 2051 2052# Register OptimizeVar in _pywrapcp: 2053_pywrapcp.OptimizeVar_swigregister(OptimizeVar) 2054 2055class SearchLimit(SearchMonitor): 2056 r""" Base class of all search limits.""" 2057 2058 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2059 2060 def __init__(self, *args, **kwargs): 2061 raise AttributeError("No constructor defined - class is abstract") 2062 __repr__ = _swig_repr 2063 __swig_destroy__ = _pywrapcp.delete_SearchLimit 2064 2065 def Crossed(self) -> "bool": 2066 r""" Returns true if the limit has been crossed.""" 2067 return _pywrapcp.SearchLimit_Crossed(self) 2068 2069 def Check(self) -> "bool": 2070 r""" This method is called to check the status of the limit. A return value of true indicates that we have indeed crossed the limit. In that case, this method will not be called again and the remaining search will be discarded.""" 2071 return _pywrapcp.SearchLimit_Check(self) 2072 2073 def Init(self) -> "void": 2074 r""" This method is called when the search limit is initialized.""" 2075 return _pywrapcp.SearchLimit_Init(self) 2076 2077 def EnterSearch(self) -> "void": 2078 r""" Internal methods.""" 2079 return _pywrapcp.SearchLimit_EnterSearch(self) 2080 2081 def BeginNextDecision(self, b: "DecisionBuilder") -> "void": 2082 return _pywrapcp.SearchLimit_BeginNextDecision(self, b) 2083 2084 def RefuteDecision(self, d: "Decision") -> "void": 2085 return _pywrapcp.SearchLimit_RefuteDecision(self, d) 2086 2087 def DebugString(self) -> "std::string": 2088 return _pywrapcp.SearchLimit_DebugString(self) 2089 2090# Register SearchLimit in _pywrapcp: 2091_pywrapcp.SearchLimit_swigregister(SearchLimit) 2092 2093class IntervalVar(PropagationBaseObject): 2094 r""" Interval variables are often used in scheduling. The main characteristics of an IntervalVar are the start position, duration, and end date. All these characteristics can be queried and set, and demons can be posted on their modifications. An important aspect is optionality: an IntervalVar can be performed or not. If unperformed, then it simply does not exist, and its characteristics cannot be accessed any more. An interval var is automatically marked as unperformed when it is not consistent anymore (start greater than end, duration < 0...)""" 2095 2096 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2097 2098 def __init__(self, *args, **kwargs): 2099 raise AttributeError("No constructor defined - class is abstract") 2100 2101 def StartMin(self) -> "int64_t": 2102 r""" These methods query, set, and watch the start position of the interval var.""" 2103 return _pywrapcp.IntervalVar_StartMin(self) 2104 2105 def StartMax(self) -> "int64_t": 2106 return _pywrapcp.IntervalVar_StartMax(self) 2107 2108 def SetStartMin(self, m: "int64_t") -> "void": 2109 return _pywrapcp.IntervalVar_SetStartMin(self, m) 2110 2111 def SetStartMax(self, m: "int64_t") -> "void": 2112 return _pywrapcp.IntervalVar_SetStartMax(self, m) 2113 2114 def SetStartRange(self, mi: "int64_t", ma: "int64_t") -> "void": 2115 return _pywrapcp.IntervalVar_SetStartRange(self, mi, ma) 2116 2117 def OldStartMin(self) -> "int64_t": 2118 return _pywrapcp.IntervalVar_OldStartMin(self) 2119 2120 def OldStartMax(self) -> "int64_t": 2121 return _pywrapcp.IntervalVar_OldStartMax(self) 2122 2123 def WhenStartRange(self, *args) -> "void": 2124 return _pywrapcp.IntervalVar_WhenStartRange(self, *args) 2125 2126 def WhenStartBound(self, *args) -> "void": 2127 return _pywrapcp.IntervalVar_WhenStartBound(self, *args) 2128 2129 def DurationMin(self) -> "int64_t": 2130 r""" These methods query, set, and watch the duration of the interval var.""" 2131 return _pywrapcp.IntervalVar_DurationMin(self) 2132 2133 def DurationMax(self) -> "int64_t": 2134 return _pywrapcp.IntervalVar_DurationMax(self) 2135 2136 def SetDurationMin(self, m: "int64_t") -> "void": 2137 return _pywrapcp.IntervalVar_SetDurationMin(self, m) 2138 2139 def SetDurationMax(self, m: "int64_t") -> "void": 2140 return _pywrapcp.IntervalVar_SetDurationMax(self, m) 2141 2142 def SetDurationRange(self, mi: "int64_t", ma: "int64_t") -> "void": 2143 return _pywrapcp.IntervalVar_SetDurationRange(self, mi, ma) 2144 2145 def OldDurationMin(self) -> "int64_t": 2146 return _pywrapcp.IntervalVar_OldDurationMin(self) 2147 2148 def OldDurationMax(self) -> "int64_t": 2149 return _pywrapcp.IntervalVar_OldDurationMax(self) 2150 2151 def WhenDurationRange(self, *args) -> "void": 2152 return _pywrapcp.IntervalVar_WhenDurationRange(self, *args) 2153 2154 def WhenDurationBound(self, *args) -> "void": 2155 return _pywrapcp.IntervalVar_WhenDurationBound(self, *args) 2156 2157 def EndMin(self) -> "int64_t": 2158 r""" These methods query, set, and watch the end position of the interval var.""" 2159 return _pywrapcp.IntervalVar_EndMin(self) 2160 2161 def EndMax(self) -> "int64_t": 2162 return _pywrapcp.IntervalVar_EndMax(self) 2163 2164 def SetEndMin(self, m: "int64_t") -> "void": 2165 return _pywrapcp.IntervalVar_SetEndMin(self, m) 2166 2167 def SetEndMax(self, m: "int64_t") -> "void": 2168 return _pywrapcp.IntervalVar_SetEndMax(self, m) 2169 2170 def SetEndRange(self, mi: "int64_t", ma: "int64_t") -> "void": 2171 return _pywrapcp.IntervalVar_SetEndRange(self, mi, ma) 2172 2173 def OldEndMin(self) -> "int64_t": 2174 return _pywrapcp.IntervalVar_OldEndMin(self) 2175 2176 def OldEndMax(self) -> "int64_t": 2177 return _pywrapcp.IntervalVar_OldEndMax(self) 2178 2179 def WhenEndRange(self, *args) -> "void": 2180 return _pywrapcp.IntervalVar_WhenEndRange(self, *args) 2181 2182 def WhenEndBound(self, *args) -> "void": 2183 return _pywrapcp.IntervalVar_WhenEndBound(self, *args) 2184 2185 def MustBePerformed(self) -> "bool": 2186 r""" These methods query, set, and watch the performed status of the interval var.""" 2187 return _pywrapcp.IntervalVar_MustBePerformed(self) 2188 2189 def MayBePerformed(self) -> "bool": 2190 return _pywrapcp.IntervalVar_MayBePerformed(self) 2191 2192 def CannotBePerformed(self) -> "bool": 2193 return _pywrapcp.IntervalVar_CannotBePerformed(self) 2194 2195 def IsPerformedBound(self) -> "bool": 2196 return _pywrapcp.IntervalVar_IsPerformedBound(self) 2197 2198 def SetPerformed(self, val: "bool") -> "void": 2199 return _pywrapcp.IntervalVar_SetPerformed(self, val) 2200 2201 def WasPerformedBound(self) -> "bool": 2202 return _pywrapcp.IntervalVar_WasPerformedBound(self) 2203 2204 def WhenPerformedBound(self, *args) -> "void": 2205 return _pywrapcp.IntervalVar_WhenPerformedBound(self, *args) 2206 2207 def WhenAnything(self, *args) -> "void": 2208 r""" 2209 *Overload 1:* 2210 Attaches a demon awakened when anything about this interval changes. 2211 2212 | 2213 2214 *Overload 2:* 2215 Attaches a closure awakened when anything about this interval changes. 2216 """ 2217 return _pywrapcp.IntervalVar_WhenAnything(self, *args) 2218 2219 def StartExpr(self) -> "operations_research::IntExpr *": 2220 r""" These methods create expressions encapsulating the start, end and duration of the interval var. Please note that these must not be used if the interval var is unperformed.""" 2221 return _pywrapcp.IntervalVar_StartExpr(self) 2222 2223 def DurationExpr(self) -> "operations_research::IntExpr *": 2224 return _pywrapcp.IntervalVar_DurationExpr(self) 2225 2226 def EndExpr(self) -> "operations_research::IntExpr *": 2227 return _pywrapcp.IntervalVar_EndExpr(self) 2228 2229 def PerformedExpr(self) -> "operations_research::IntExpr *": 2230 return _pywrapcp.IntervalVar_PerformedExpr(self) 2231 2232 def SafeStartExpr(self, unperformed_value: "int64_t") -> "operations_research::IntExpr *": 2233 r""" These methods create expressions encapsulating the start, end and duration of the interval var. If the interval var is unperformed, they will return the unperformed_value.""" 2234 return _pywrapcp.IntervalVar_SafeStartExpr(self, unperformed_value) 2235 2236 def SafeDurationExpr(self, unperformed_value: "int64_t") -> "operations_research::IntExpr *": 2237 return _pywrapcp.IntervalVar_SafeDurationExpr(self, unperformed_value) 2238 2239 def SafeEndExpr(self, unperformed_value: "int64_t") -> "operations_research::IntExpr *": 2240 return _pywrapcp.IntervalVar_SafeEndExpr(self, unperformed_value) 2241 2242 def EndsAfterEnd(self, other: "IntervalVar") -> "operations_research::Constraint *": 2243 return _pywrapcp.IntervalVar_EndsAfterEnd(self, other) 2244 2245 def EndsAfterEndWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2246 return _pywrapcp.IntervalVar_EndsAfterEndWithDelay(self, other, delay) 2247 2248 def EndsAfterStart(self, other: "IntervalVar") -> "operations_research::Constraint *": 2249 return _pywrapcp.IntervalVar_EndsAfterStart(self, other) 2250 2251 def EndsAfterStartWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2252 return _pywrapcp.IntervalVar_EndsAfterStartWithDelay(self, other, delay) 2253 2254 def EndsAtEnd(self, other: "IntervalVar") -> "operations_research::Constraint *": 2255 return _pywrapcp.IntervalVar_EndsAtEnd(self, other) 2256 2257 def EndsAtEndWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2258 return _pywrapcp.IntervalVar_EndsAtEndWithDelay(self, other, delay) 2259 2260 def EndsAtStart(self, other: "IntervalVar") -> "operations_research::Constraint *": 2261 return _pywrapcp.IntervalVar_EndsAtStart(self, other) 2262 2263 def EndsAtStartWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2264 return _pywrapcp.IntervalVar_EndsAtStartWithDelay(self, other, delay) 2265 2266 def StartsAfterEnd(self, other: "IntervalVar") -> "operations_research::Constraint *": 2267 return _pywrapcp.IntervalVar_StartsAfterEnd(self, other) 2268 2269 def StartsAfterEndWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2270 return _pywrapcp.IntervalVar_StartsAfterEndWithDelay(self, other, delay) 2271 2272 def StartsAfterStart(self, other: "IntervalVar") -> "operations_research::Constraint *": 2273 return _pywrapcp.IntervalVar_StartsAfterStart(self, other) 2274 2275 def StartsAfterStartWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2276 return _pywrapcp.IntervalVar_StartsAfterStartWithDelay(self, other, delay) 2277 2278 def StartsAtEnd(self, other: "IntervalVar") -> "operations_research::Constraint *": 2279 return _pywrapcp.IntervalVar_StartsAtEnd(self, other) 2280 2281 def StartsAtEndWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2282 return _pywrapcp.IntervalVar_StartsAtEndWithDelay(self, other, delay) 2283 2284 def StartsAtStart(self, other: "IntervalVar") -> "operations_research::Constraint *": 2285 return _pywrapcp.IntervalVar_StartsAtStart(self, other) 2286 2287 def StartsAtStartWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2288 return _pywrapcp.IntervalVar_StartsAtStartWithDelay(self, other, delay) 2289 2290 def StaysInSync(self, other: "IntervalVar") -> "operations_research::Constraint *": 2291 return _pywrapcp.IntervalVar_StaysInSync(self, other) 2292 2293 def StaysInSyncWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2294 return _pywrapcp.IntervalVar_StaysInSyncWithDelay(self, other, delay) 2295 2296 def EndsAfter(self, date: "int64_t") -> "operations_research::Constraint *": 2297 return _pywrapcp.IntervalVar_EndsAfter(self, date) 2298 2299 def EndsAt(self, date: "int64_t") -> "operations_research::Constraint *": 2300 return _pywrapcp.IntervalVar_EndsAt(self, date) 2301 2302 def EndsBefore(self, date: "int64_t") -> "operations_research::Constraint *": 2303 return _pywrapcp.IntervalVar_EndsBefore(self, date) 2304 2305 def StartsAfter(self, date: "int64_t") -> "operations_research::Constraint *": 2306 return _pywrapcp.IntervalVar_StartsAfter(self, date) 2307 2308 def StartsAt(self, date: "int64_t") -> "operations_research::Constraint *": 2309 return _pywrapcp.IntervalVar_StartsAt(self, date) 2310 2311 def StartsBefore(self, date: "int64_t") -> "operations_research::Constraint *": 2312 return _pywrapcp.IntervalVar_StartsBefore(self, date) 2313 2314 def CrossesDate(self, date: "int64_t") -> "operations_research::Constraint *": 2315 return _pywrapcp.IntervalVar_CrossesDate(self, date) 2316 2317 def AvoidsDate(self, date: "int64_t") -> "operations_research::Constraint *": 2318 return _pywrapcp.IntervalVar_AvoidsDate(self, date) 2319 2320 def __repr__(self) -> "std::string": 2321 return _pywrapcp.IntervalVar___repr__(self) 2322 2323 def __str__(self) -> "std::string": 2324 return _pywrapcp.IntervalVar___str__(self) 2325 2326# Register IntervalVar in _pywrapcp: 2327_pywrapcp.IntervalVar_swigregister(IntervalVar) 2328 2329class SequenceVar(PropagationBaseObject): 2330 r""" A sequence variable is a variable whose domain is a set of possible orderings of the interval variables. It allows ordering of tasks. It has two sets of methods: ComputePossibleFirstsAndLasts(), which returns the list of interval variables that can be ranked first or last; and RankFirst/RankNotFirst/RankLast/RankNotLast, which can be used to create the search decision.""" 2331 2332 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2333 2334 def __init__(self, *args, **kwargs): 2335 raise AttributeError("No constructor defined") 2336 2337 def DebugString(self) -> "std::string": 2338 return _pywrapcp.SequenceVar_DebugString(self) 2339 2340 def RankFirst(self, index: "int") -> "void": 2341 r""" Ranks the index_th interval var first of all unranked interval vars. After that, it will no longer be considered ranked.""" 2342 return _pywrapcp.SequenceVar_RankFirst(self, index) 2343 2344 def RankNotFirst(self, index: "int") -> "void": 2345 r""" Indicates that the index_th interval var will not be ranked first of all currently unranked interval vars.""" 2346 return _pywrapcp.SequenceVar_RankNotFirst(self, index) 2347 2348 def RankLast(self, index: "int") -> "void": 2349 r""" Ranks the index_th interval var first of all unranked interval vars. After that, it will no longer be considered ranked.""" 2350 return _pywrapcp.SequenceVar_RankLast(self, index) 2351 2352 def RankNotLast(self, index: "int") -> "void": 2353 r""" Indicates that the index_th interval var will not be ranked first of all currently unranked interval vars.""" 2354 return _pywrapcp.SequenceVar_RankNotLast(self, index) 2355 2356 def Interval(self, index: "int") -> "operations_research::IntervalVar *": 2357 r""" Returns the index_th interval of the sequence.""" 2358 return _pywrapcp.SequenceVar_Interval(self, index) 2359 2360 def Next(self, index: "int") -> "operations_research::IntVar *": 2361 r""" Returns the next of the index_th interval of the sequence.""" 2362 return _pywrapcp.SequenceVar_Next(self, index) 2363 2364 def Size(self) -> "int64_t": 2365 r""" Returns the number of interval vars in the sequence.""" 2366 return _pywrapcp.SequenceVar_Size(self) 2367 2368 def __repr__(self) -> "std::string": 2369 return _pywrapcp.SequenceVar___repr__(self) 2370 2371 def __str__(self) -> "std::string": 2372 return _pywrapcp.SequenceVar___str__(self) 2373 2374# Register SequenceVar in _pywrapcp: 2375_pywrapcp.SequenceVar_swigregister(SequenceVar) 2376 2377class AssignmentElement(object): 2378 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2379 2380 def __init__(self, *args, **kwargs): 2381 raise AttributeError("No constructor defined") 2382 __repr__ = _swig_repr 2383 2384 def Activate(self) -> "void": 2385 return _pywrapcp.AssignmentElement_Activate(self) 2386 2387 def Deactivate(self) -> "void": 2388 return _pywrapcp.AssignmentElement_Deactivate(self) 2389 2390 def Activated(self) -> "bool": 2391 return _pywrapcp.AssignmentElement_Activated(self) 2392 __swig_destroy__ = _pywrapcp.delete_AssignmentElement 2393 2394# Register AssignmentElement in _pywrapcp: 2395_pywrapcp.AssignmentElement_swigregister(AssignmentElement) 2396 2397class IntVarElement(AssignmentElement): 2398 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2399 2400 def __init__(self, *args, **kwargs): 2401 raise AttributeError("No constructor defined") 2402 __repr__ = _swig_repr 2403 2404 def Var(self) -> "operations_research::IntVar *": 2405 return _pywrapcp.IntVarElement_Var(self) 2406 2407 def Min(self) -> "int64_t": 2408 return _pywrapcp.IntVarElement_Min(self) 2409 2410 def SetMin(self, m: "int64_t") -> "void": 2411 return _pywrapcp.IntVarElement_SetMin(self, m) 2412 2413 def Max(self) -> "int64_t": 2414 return _pywrapcp.IntVarElement_Max(self) 2415 2416 def SetMax(self, m: "int64_t") -> "void": 2417 return _pywrapcp.IntVarElement_SetMax(self, m) 2418 2419 def Value(self) -> "int64_t": 2420 return _pywrapcp.IntVarElement_Value(self) 2421 2422 def Bound(self) -> "bool": 2423 return _pywrapcp.IntVarElement_Bound(self) 2424 2425 def SetRange(self, l: "int64_t", u: "int64_t") -> "void": 2426 return _pywrapcp.IntVarElement_SetRange(self, l, u) 2427 2428 def SetValue(self, v: "int64_t") -> "void": 2429 return _pywrapcp.IntVarElement_SetValue(self, v) 2430 2431 def __eq__(self, element: "IntVarElement") -> "bool": 2432 return _pywrapcp.IntVarElement___eq__(self, element) 2433 2434 def __ne__(self, element: "IntVarElement") -> "bool": 2435 return _pywrapcp.IntVarElement___ne__(self, element) 2436 __swig_destroy__ = _pywrapcp.delete_IntVarElement 2437 2438# Register IntVarElement in _pywrapcp: 2439_pywrapcp.IntVarElement_swigregister(IntVarElement) 2440 2441class IntervalVarElement(AssignmentElement): 2442 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2443 2444 def __init__(self, *args, **kwargs): 2445 raise AttributeError("No constructor defined") 2446 __repr__ = _swig_repr 2447 2448 def Var(self) -> "operations_research::IntervalVar *": 2449 return _pywrapcp.IntervalVarElement_Var(self) 2450 2451 def StartMin(self) -> "int64_t": 2452 return _pywrapcp.IntervalVarElement_StartMin(self) 2453 2454 def StartMax(self) -> "int64_t": 2455 return _pywrapcp.IntervalVarElement_StartMax(self) 2456 2457 def StartValue(self) -> "int64_t": 2458 return _pywrapcp.IntervalVarElement_StartValue(self) 2459 2460 def DurationMin(self) -> "int64_t": 2461 return _pywrapcp.IntervalVarElement_DurationMin(self) 2462 2463 def DurationMax(self) -> "int64_t": 2464 return _pywrapcp.IntervalVarElement_DurationMax(self) 2465 2466 def DurationValue(self) -> "int64_t": 2467 return _pywrapcp.IntervalVarElement_DurationValue(self) 2468 2469 def EndMin(self) -> "int64_t": 2470 return _pywrapcp.IntervalVarElement_EndMin(self) 2471 2472 def EndMax(self) -> "int64_t": 2473 return _pywrapcp.IntervalVarElement_EndMax(self) 2474 2475 def EndValue(self) -> "int64_t": 2476 return _pywrapcp.IntervalVarElement_EndValue(self) 2477 2478 def PerformedMin(self) -> "int64_t": 2479 return _pywrapcp.IntervalVarElement_PerformedMin(self) 2480 2481 def PerformedMax(self) -> "int64_t": 2482 return _pywrapcp.IntervalVarElement_PerformedMax(self) 2483 2484 def PerformedValue(self) -> "int64_t": 2485 return _pywrapcp.IntervalVarElement_PerformedValue(self) 2486 2487 def SetStartMin(self, m: "int64_t") -> "void": 2488 return _pywrapcp.IntervalVarElement_SetStartMin(self, m) 2489 2490 def SetStartMax(self, m: "int64_t") -> "void": 2491 return _pywrapcp.IntervalVarElement_SetStartMax(self, m) 2492 2493 def SetStartRange(self, mi: "int64_t", ma: "int64_t") -> "void": 2494 return _pywrapcp.IntervalVarElement_SetStartRange(self, mi, ma) 2495 2496 def SetStartValue(self, v: "int64_t") -> "void": 2497 return _pywrapcp.IntervalVarElement_SetStartValue(self, v) 2498 2499 def SetDurationMin(self, m: "int64_t") -> "void": 2500 return _pywrapcp.IntervalVarElement_SetDurationMin(self, m) 2501 2502 def SetDurationMax(self, m: "int64_t") -> "void": 2503 return _pywrapcp.IntervalVarElement_SetDurationMax(self, m) 2504 2505 def SetDurationRange(self, mi: "int64_t", ma: "int64_t") -> "void": 2506 return _pywrapcp.IntervalVarElement_SetDurationRange(self, mi, ma) 2507 2508 def SetDurationValue(self, v: "int64_t") -> "void": 2509 return _pywrapcp.IntervalVarElement_SetDurationValue(self, v) 2510 2511 def SetEndMin(self, m: "int64_t") -> "void": 2512 return _pywrapcp.IntervalVarElement_SetEndMin(self, m) 2513 2514 def SetEndMax(self, m: "int64_t") -> "void": 2515 return _pywrapcp.IntervalVarElement_SetEndMax(self, m) 2516 2517 def SetEndRange(self, mi: "int64_t", ma: "int64_t") -> "void": 2518 return _pywrapcp.IntervalVarElement_SetEndRange(self, mi, ma) 2519 2520 def SetEndValue(self, v: "int64_t") -> "void": 2521 return _pywrapcp.IntervalVarElement_SetEndValue(self, v) 2522 2523 def SetPerformedMin(self, m: "int64_t") -> "void": 2524 return _pywrapcp.IntervalVarElement_SetPerformedMin(self, m) 2525 2526 def SetPerformedMax(self, m: "int64_t") -> "void": 2527 return _pywrapcp.IntervalVarElement_SetPerformedMax(self, m) 2528 2529 def SetPerformedRange(self, mi: "int64_t", ma: "int64_t") -> "void": 2530 return _pywrapcp.IntervalVarElement_SetPerformedRange(self, mi, ma) 2531 2532 def SetPerformedValue(self, v: "int64_t") -> "void": 2533 return _pywrapcp.IntervalVarElement_SetPerformedValue(self, v) 2534 2535 def __eq__(self, element: "IntervalVarElement") -> "bool": 2536 return _pywrapcp.IntervalVarElement___eq__(self, element) 2537 2538 def __ne__(self, element: "IntervalVarElement") -> "bool": 2539 return _pywrapcp.IntervalVarElement___ne__(self, element) 2540 __swig_destroy__ = _pywrapcp.delete_IntervalVarElement 2541 2542# Register IntervalVarElement in _pywrapcp: 2543_pywrapcp.IntervalVarElement_swigregister(IntervalVarElement) 2544 2545class SequenceVarElement(AssignmentElement): 2546 r""" The SequenceVarElement stores a partial representation of ranked interval variables in the underlying sequence variable. This representation consists of three vectors: - the forward sequence. That is the list of interval variables ranked first in the sequence. The first element of the backward sequence is the first interval in the sequence variable. - the backward sequence. That is the list of interval variables ranked last in the sequence. The first element of the backward sequence is the last interval in the sequence variable. - The list of unperformed interval variables. Furthermore, if all performed variables are ranked, then by convention, the forward_sequence will contain all such variables and the backward_sequence will be empty.""" 2547 2548 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2549 2550 def __init__(self, *args, **kwargs): 2551 raise AttributeError("No constructor defined") 2552 __repr__ = _swig_repr 2553 2554 def Var(self) -> "operations_research::SequenceVar *": 2555 return _pywrapcp.SequenceVarElement_Var(self) 2556 2557 def ForwardSequence(self) -> "std::vector< int > const &": 2558 return _pywrapcp.SequenceVarElement_ForwardSequence(self) 2559 2560 def BackwardSequence(self) -> "std::vector< int > const &": 2561 return _pywrapcp.SequenceVarElement_BackwardSequence(self) 2562 2563 def Unperformed(self) -> "std::vector< int > const &": 2564 return _pywrapcp.SequenceVarElement_Unperformed(self) 2565 2566 def SetSequence(self, forward_sequence: "std::vector< int > const &", backward_sequence: "std::vector< int > const &", unperformed: "std::vector< int > const &") -> "void": 2567 return _pywrapcp.SequenceVarElement_SetSequence(self, forward_sequence, backward_sequence, unperformed) 2568 2569 def SetForwardSequence(self, forward_sequence: "std::vector< int > const &") -> "void": 2570 return _pywrapcp.SequenceVarElement_SetForwardSequence(self, forward_sequence) 2571 2572 def SetBackwardSequence(self, backward_sequence: "std::vector< int > const &") -> "void": 2573 return _pywrapcp.SequenceVarElement_SetBackwardSequence(self, backward_sequence) 2574 2575 def SetUnperformed(self, unperformed: "std::vector< int > const &") -> "void": 2576 return _pywrapcp.SequenceVarElement_SetUnperformed(self, unperformed) 2577 2578 def __eq__(self, element: "SequenceVarElement") -> "bool": 2579 return _pywrapcp.SequenceVarElement___eq__(self, element) 2580 2581 def __ne__(self, element: "SequenceVarElement") -> "bool": 2582 return _pywrapcp.SequenceVarElement___ne__(self, element) 2583 __swig_destroy__ = _pywrapcp.delete_SequenceVarElement 2584 2585# Register SequenceVarElement in _pywrapcp: 2586_pywrapcp.SequenceVarElement_swigregister(SequenceVarElement) 2587 2588class Assignment(PropagationBaseObject): 2589 r""" An Assignment is a variable -> domains mapping, used to report solutions to the user.""" 2590 2591 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2592 2593 def __init__(self, *args, **kwargs): 2594 raise AttributeError("No constructor defined") 2595 __repr__ = _swig_repr 2596 2597 def Clear(self) -> "void": 2598 return _pywrapcp.Assignment_Clear(self) 2599 2600 def Empty(self) -> "bool": 2601 return _pywrapcp.Assignment_Empty(self) 2602 2603 def Size(self) -> "int": 2604 return _pywrapcp.Assignment_Size(self) 2605 2606 def NumIntVars(self) -> "int": 2607 return _pywrapcp.Assignment_NumIntVars(self) 2608 2609 def NumIntervalVars(self) -> "int": 2610 return _pywrapcp.Assignment_NumIntervalVars(self) 2611 2612 def NumSequenceVars(self) -> "int": 2613 return _pywrapcp.Assignment_NumSequenceVars(self) 2614 2615 def Store(self) -> "void": 2616 return _pywrapcp.Assignment_Store(self) 2617 2618 def Restore(self) -> "void": 2619 return _pywrapcp.Assignment_Restore(self) 2620 2621 def Load(self, *args) -> "void": 2622 return _pywrapcp.Assignment_Load(self, *args) 2623 2624 def Save(self, *args) -> "void": 2625 return _pywrapcp.Assignment_Save(self, *args) 2626 2627 def AddObjective(self, v: "IntVar") -> "void": 2628 return _pywrapcp.Assignment_AddObjective(self, v) 2629 2630 def Objective(self) -> "operations_research::IntVar *": 2631 return _pywrapcp.Assignment_Objective(self) 2632 2633 def HasObjective(self) -> "bool": 2634 return _pywrapcp.Assignment_HasObjective(self) 2635 2636 def ObjectiveMin(self) -> "int64_t": 2637 return _pywrapcp.Assignment_ObjectiveMin(self) 2638 2639 def ObjectiveMax(self) -> "int64_t": 2640 return _pywrapcp.Assignment_ObjectiveMax(self) 2641 2642 def ObjectiveValue(self) -> "int64_t": 2643 return _pywrapcp.Assignment_ObjectiveValue(self) 2644 2645 def ObjectiveBound(self) -> "bool": 2646 return _pywrapcp.Assignment_ObjectiveBound(self) 2647 2648 def SetObjectiveMin(self, m: "int64_t") -> "void": 2649 return _pywrapcp.Assignment_SetObjectiveMin(self, m) 2650 2651 def SetObjectiveMax(self, m: "int64_t") -> "void": 2652 return _pywrapcp.Assignment_SetObjectiveMax(self, m) 2653 2654 def SetObjectiveValue(self, value: "int64_t") -> "void": 2655 return _pywrapcp.Assignment_SetObjectiveValue(self, value) 2656 2657 def SetObjectiveRange(self, l: "int64_t", u: "int64_t") -> "void": 2658 return _pywrapcp.Assignment_SetObjectiveRange(self, l, u) 2659 2660 def Min(self, var: "IntVar") -> "int64_t": 2661 return _pywrapcp.Assignment_Min(self, var) 2662 2663 def Max(self, var: "IntVar") -> "int64_t": 2664 return _pywrapcp.Assignment_Max(self, var) 2665 2666 def Value(self, var: "IntVar") -> "int64_t": 2667 return _pywrapcp.Assignment_Value(self, var) 2668 2669 def Bound(self, var: "IntVar") -> "bool": 2670 return _pywrapcp.Assignment_Bound(self, var) 2671 2672 def SetMin(self, var: "IntVar", m: "int64_t") -> "void": 2673 return _pywrapcp.Assignment_SetMin(self, var, m) 2674 2675 def SetMax(self, var: "IntVar", m: "int64_t") -> "void": 2676 return _pywrapcp.Assignment_SetMax(self, var, m) 2677 2678 def SetRange(self, var: "IntVar", l: "int64_t", u: "int64_t") -> "void": 2679 return _pywrapcp.Assignment_SetRange(self, var, l, u) 2680 2681 def SetValue(self, var: "IntVar", value: "int64_t") -> "void": 2682 return _pywrapcp.Assignment_SetValue(self, var, value) 2683 2684 def StartMin(self, var: "IntervalVar") -> "int64_t": 2685 return _pywrapcp.Assignment_StartMin(self, var) 2686 2687 def StartMax(self, var: "IntervalVar") -> "int64_t": 2688 return _pywrapcp.Assignment_StartMax(self, var) 2689 2690 def StartValue(self, var: "IntervalVar") -> "int64_t": 2691 return _pywrapcp.Assignment_StartValue(self, var) 2692 2693 def DurationMin(self, var: "IntervalVar") -> "int64_t": 2694 return _pywrapcp.Assignment_DurationMin(self, var) 2695 2696 def DurationMax(self, var: "IntervalVar") -> "int64_t": 2697 return _pywrapcp.Assignment_DurationMax(self, var) 2698 2699 def DurationValue(self, var: "IntervalVar") -> "int64_t": 2700 return _pywrapcp.Assignment_DurationValue(self, var) 2701 2702 def EndMin(self, var: "IntervalVar") -> "int64_t": 2703 return _pywrapcp.Assignment_EndMin(self, var) 2704 2705 def EndMax(self, var: "IntervalVar") -> "int64_t": 2706 return _pywrapcp.Assignment_EndMax(self, var) 2707 2708 def EndValue(self, var: "IntervalVar") -> "int64_t": 2709 return _pywrapcp.Assignment_EndValue(self, var) 2710 2711 def PerformedMin(self, var: "IntervalVar") -> "int64_t": 2712 return _pywrapcp.Assignment_PerformedMin(self, var) 2713 2714 def PerformedMax(self, var: "IntervalVar") -> "int64_t": 2715 return _pywrapcp.Assignment_PerformedMax(self, var) 2716 2717 def PerformedValue(self, var: "IntervalVar") -> "int64_t": 2718 return _pywrapcp.Assignment_PerformedValue(self, var) 2719 2720 def SetStartMin(self, var: "IntervalVar", m: "int64_t") -> "void": 2721 return _pywrapcp.Assignment_SetStartMin(self, var, m) 2722 2723 def SetStartMax(self, var: "IntervalVar", m: "int64_t") -> "void": 2724 return _pywrapcp.Assignment_SetStartMax(self, var, m) 2725 2726 def SetStartRange(self, var: "IntervalVar", mi: "int64_t", ma: "int64_t") -> "void": 2727 return _pywrapcp.Assignment_SetStartRange(self, var, mi, ma) 2728 2729 def SetStartValue(self, var: "IntervalVar", value: "int64_t") -> "void": 2730 return _pywrapcp.Assignment_SetStartValue(self, var, value) 2731 2732 def SetDurationMin(self, var: "IntervalVar", m: "int64_t") -> "void": 2733 return _pywrapcp.Assignment_SetDurationMin(self, var, m) 2734 2735 def SetDurationMax(self, var: "IntervalVar", m: "int64_t") -> "void": 2736 return _pywrapcp.Assignment_SetDurationMax(self, var, m) 2737 2738 def SetDurationRange(self, var: "IntervalVar", mi: "int64_t", ma: "int64_t") -> "void": 2739 return _pywrapcp.Assignment_SetDurationRange(self, var, mi, ma) 2740 2741 def SetDurationValue(self, var: "IntervalVar", value: "int64_t") -> "void": 2742 return _pywrapcp.Assignment_SetDurationValue(self, var, value) 2743 2744 def SetEndMin(self, var: "IntervalVar", m: "int64_t") -> "void": 2745 return _pywrapcp.Assignment_SetEndMin(self, var, m) 2746 2747 def SetEndMax(self, var: "IntervalVar", m: "int64_t") -> "void": 2748 return _pywrapcp.Assignment_SetEndMax(self, var, m) 2749 2750 def SetEndRange(self, var: "IntervalVar", mi: "int64_t", ma: "int64_t") -> "void": 2751 return _pywrapcp.Assignment_SetEndRange(self, var, mi, ma) 2752 2753 def SetEndValue(self, var: "IntervalVar", value: "int64_t") -> "void": 2754 return _pywrapcp.Assignment_SetEndValue(self, var, value) 2755 2756 def SetPerformedMin(self, var: "IntervalVar", m: "int64_t") -> "void": 2757 return _pywrapcp.Assignment_SetPerformedMin(self, var, m) 2758 2759 def SetPerformedMax(self, var: "IntervalVar", m: "int64_t") -> "void": 2760 return _pywrapcp.Assignment_SetPerformedMax(self, var, m) 2761 2762 def SetPerformedRange(self, var: "IntervalVar", mi: "int64_t", ma: "int64_t") -> "void": 2763 return _pywrapcp.Assignment_SetPerformedRange(self, var, mi, ma) 2764 2765 def SetPerformedValue(self, var: "IntervalVar", value: "int64_t") -> "void": 2766 return _pywrapcp.Assignment_SetPerformedValue(self, var, value) 2767 2768 def Add(self, *args) -> "void": 2769 return _pywrapcp.Assignment_Add(self, *args) 2770 2771 def ForwardSequence(self, var: "SequenceVar") -> "std::vector< int > const &": 2772 return _pywrapcp.Assignment_ForwardSequence(self, var) 2773 2774 def BackwardSequence(self, var: "SequenceVar") -> "std::vector< int > const &": 2775 return _pywrapcp.Assignment_BackwardSequence(self, var) 2776 2777 def Unperformed(self, var: "SequenceVar") -> "std::vector< int > const &": 2778 return _pywrapcp.Assignment_Unperformed(self, var) 2779 2780 def SetSequence(self, var: "SequenceVar", forward_sequence: "std::vector< int > const &", backward_sequence: "std::vector< int > const &", unperformed: "std::vector< int > const &") -> "void": 2781 return _pywrapcp.Assignment_SetSequence(self, var, forward_sequence, backward_sequence, unperformed) 2782 2783 def SetForwardSequence(self, var: "SequenceVar", forward_sequence: "std::vector< int > const &") -> "void": 2784 return _pywrapcp.Assignment_SetForwardSequence(self, var, forward_sequence) 2785 2786 def SetBackwardSequence(self, var: "SequenceVar", backward_sequence: "std::vector< int > const &") -> "void": 2787 return _pywrapcp.Assignment_SetBackwardSequence(self, var, backward_sequence) 2788 2789 def SetUnperformed(self, var: "SequenceVar", unperformed: "std::vector< int > const &") -> "void": 2790 return _pywrapcp.Assignment_SetUnperformed(self, var, unperformed) 2791 2792 def Activate(self, *args) -> "void": 2793 return _pywrapcp.Assignment_Activate(self, *args) 2794 2795 def Deactivate(self, *args) -> "void": 2796 return _pywrapcp.Assignment_Deactivate(self, *args) 2797 2798 def Activated(self, *args) -> "bool": 2799 return _pywrapcp.Assignment_Activated(self, *args) 2800 2801 def DebugString(self) -> "std::string": 2802 return _pywrapcp.Assignment_DebugString(self) 2803 2804 def IntVarContainer(self) -> "operations_research::Assignment::IntContainer const &": 2805 return _pywrapcp.Assignment_IntVarContainer(self) 2806 2807 def MutableIntVarContainer(self) -> "operations_research::Assignment::IntContainer *": 2808 return _pywrapcp.Assignment_MutableIntVarContainer(self) 2809 2810 def IntervalVarContainer(self) -> "operations_research::Assignment::IntervalContainer const &": 2811 return _pywrapcp.Assignment_IntervalVarContainer(self) 2812 2813 def MutableIntervalVarContainer(self) -> "operations_research::Assignment::IntervalContainer *": 2814 return _pywrapcp.Assignment_MutableIntervalVarContainer(self) 2815 2816 def SequenceVarContainer(self) -> "operations_research::Assignment::SequenceContainer const &": 2817 return _pywrapcp.Assignment_SequenceVarContainer(self) 2818 2819 def MutableSequenceVarContainer(self) -> "operations_research::Assignment::SequenceContainer *": 2820 return _pywrapcp.Assignment_MutableSequenceVarContainer(self) 2821 2822 def __eq__(self, assignment: "Assignment") -> "bool": 2823 return _pywrapcp.Assignment___eq__(self, assignment) 2824 2825 def __ne__(self, assignment: "Assignment") -> "bool": 2826 return _pywrapcp.Assignment___ne__(self, assignment) 2827 2828# Register Assignment in _pywrapcp: 2829_pywrapcp.Assignment_swigregister(Assignment) 2830 2831 2832def __lshift__(*args) -> "std::ostream &": 2833 return _pywrapcp.__lshift__(*args) 2834class Pack(Constraint): 2835 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2836 2837 def __init__(self, *args, **kwargs): 2838 raise AttributeError("No constructor defined") 2839 __repr__ = _swig_repr 2840 2841 def AddWeightedSumLessOrEqualConstantDimension(self, *args) -> "void": 2842 r""" 2843 *Overload 1:* 2844 Dimensions are additional constraints than can restrict what is possible with the pack constraint. It can be used to set capacity limits, to count objects per bin, to compute unassigned penalties... This dimension imposes that for all bins b, the weighted sum (weights[i]) of all objects i assigned to 'b' is less or equal 'bounds[b]'. 2845 2846 | 2847 2848 *Overload 2:* 2849 This dimension imposes that for all bins b, the weighted sum (weights->Run(i)) of all objects i assigned to 'b' is less or equal to 'bounds[b]'. Ownership of the callback is transferred to the pack constraint. 2850 2851 | 2852 2853 *Overload 3:* 2854 This dimension imposes that for all bins b, the weighted sum (weights->Run(i, b) of all objects i assigned to 'b' is less or equal to 'bounds[b]'. Ownership of the callback is transferred to the pack constraint. 2855 """ 2856 return _pywrapcp.Pack_AddWeightedSumLessOrEqualConstantDimension(self, *args) 2857 2858 def AddWeightedSumEqualVarDimension(self, *args) -> "void": 2859 r""" 2860 *Overload 1:* 2861 This dimension imposes that for all bins b, the weighted sum (weights[i]) of all objects i assigned to 'b' is equal to loads[b]. 2862 2863 | 2864 2865 *Overload 2:* 2866 This dimension imposes that for all bins b, the weighted sum (weights->Run(i, b)) of all objects i assigned to 'b' is equal to loads[b]. 2867 """ 2868 return _pywrapcp.Pack_AddWeightedSumEqualVarDimension(self, *args) 2869 2870 def AddSumVariableWeightsLessOrEqualConstantDimension(self, usage: "std::vector< operations_research::IntVar * > const &", capacity: "std::vector< int64_t > const &") -> "void": 2871 r""" This dimension imposes: forall b in bins, sum (i in items: usage[i] * is_assigned(i, b)) <= capacity[b] where is_assigned(i, b) is true if and only if item i is assigned to the bin b. This can be used to model shapes of items by linking variables of the same item on parallel dimensions with an allowed assignment constraint.""" 2872 return _pywrapcp.Pack_AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity) 2873 2874 def AddWeightedSumOfAssignedDimension(self, weights: "std::vector< int64_t > const &", cost_var: "IntVar") -> "void": 2875 r""" This dimension enforces that cost_var == sum of weights[i] for all objects 'i' assigned to a bin.""" 2876 return _pywrapcp.Pack_AddWeightedSumOfAssignedDimension(self, weights, cost_var) 2877 2878 def AddCountUsedBinDimension(self, count_var: "IntVar") -> "void": 2879 r""" This dimension links 'count_var' to the actual number of bins used in the pack.""" 2880 return _pywrapcp.Pack_AddCountUsedBinDimension(self, count_var) 2881 2882 def AddCountAssignedItemsDimension(self, count_var: "IntVar") -> "void": 2883 r""" This dimension links 'count_var' to the actual number of items assigned to a bin in the pack.""" 2884 return _pywrapcp.Pack_AddCountAssignedItemsDimension(self, count_var) 2885 2886 def Post(self) -> "void": 2887 return _pywrapcp.Pack_Post(self) 2888 2889 def InitialPropagateWrapper(self) -> "void": 2890 return _pywrapcp.Pack_InitialPropagateWrapper(self) 2891 2892 def DebugString(self) -> "std::string": 2893 return _pywrapcp.Pack_DebugString(self) 2894 2895# Register Pack in _pywrapcp: 2896_pywrapcp.Pack_swigregister(Pack) 2897 2898class DisjunctiveConstraint(Constraint): 2899 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2900 2901 def __init__(self, *args, **kwargs): 2902 raise AttributeError("No constructor defined - class is abstract") 2903 __repr__ = _swig_repr 2904 2905 def SequenceVar(self) -> "operations_research::SequenceVar *": 2906 r""" Creates a sequence variable from the constraint.""" 2907 return _pywrapcp.DisjunctiveConstraint_SequenceVar(self) 2908 2909 def SetTransitionTime(self, transition_time: "operations_research::Solver::IndexEvaluator2") -> "void": 2910 r""" Add a transition time between intervals. It forces the distance between the end of interval a and start of interval b that follows it to be at least transition_time(a, b). This function must always return a positive or null value.""" 2911 return _pywrapcp.DisjunctiveConstraint_SetTransitionTime(self, transition_time) 2912 2913 def TransitionTime(self, before_index: "int", after_index: "int") -> "int64_t": 2914 return _pywrapcp.DisjunctiveConstraint_TransitionTime(self, before_index, after_index) 2915 2916# Register DisjunctiveConstraint in _pywrapcp: 2917_pywrapcp.DisjunctiveConstraint_swigregister(DisjunctiveConstraint) 2918 2919class RevInteger(object): 2920 r""" This class adds reversibility to a POD type. It contains the stamp optimization. i.e. the SaveValue call is done only once per node of the search tree. Please note that actual stamps always starts at 1, thus an initial value of 0 will always trigger the first SaveValue.""" 2921 2922 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2923 __repr__ = _swig_repr 2924 2925 def __init__(self, val: "long const &"): 2926 _pywrapcp.RevInteger_swiginit(self, _pywrapcp.new_RevInteger(val)) 2927 2928 def Value(self) -> "long const &": 2929 return _pywrapcp.RevInteger_Value(self) 2930 2931 def SetValue(self, s: "Solver", val: "long const &") -> "void": 2932 return _pywrapcp.RevInteger_SetValue(self, s, val) 2933 __swig_destroy__ = _pywrapcp.delete_RevInteger 2934 2935# Register RevInteger in _pywrapcp: 2936_pywrapcp.RevInteger_swigregister(RevInteger) 2937 2938class NumericalRevInteger(RevInteger): 2939 r""" Subclass of Rev<T> which adds numerical operations.""" 2940 2941 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2942 __repr__ = _swig_repr 2943 2944 def __init__(self, val: "long const &"): 2945 _pywrapcp.NumericalRevInteger_swiginit(self, _pywrapcp.new_NumericalRevInteger(val)) 2946 2947 def Add(self, s: "Solver", to_add: "long const &") -> "void": 2948 return _pywrapcp.NumericalRevInteger_Add(self, s, to_add) 2949 2950 def Incr(self, s: "Solver") -> "void": 2951 return _pywrapcp.NumericalRevInteger_Incr(self, s) 2952 2953 def Decr(self, s: "Solver") -> "void": 2954 return _pywrapcp.NumericalRevInteger_Decr(self, s) 2955 __swig_destroy__ = _pywrapcp.delete_NumericalRevInteger 2956 2957# Register NumericalRevInteger in _pywrapcp: 2958_pywrapcp.NumericalRevInteger_swigregister(NumericalRevInteger) 2959 2960class RevBool(object): 2961 r""" This class adds reversibility to a POD type. It contains the stamp optimization. i.e. the SaveValue call is done only once per node of the search tree. Please note that actual stamps always starts at 1, thus an initial value of 0 will always trigger the first SaveValue.""" 2962 2963 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2964 __repr__ = _swig_repr 2965 2966 def __init__(self, val: "bool const &"): 2967 _pywrapcp.RevBool_swiginit(self, _pywrapcp.new_RevBool(val)) 2968 2969 def Value(self) -> "bool const &": 2970 return _pywrapcp.RevBool_Value(self) 2971 2972 def SetValue(self, s: "Solver", val: "bool const &") -> "void": 2973 return _pywrapcp.RevBool_SetValue(self, s, val) 2974 __swig_destroy__ = _pywrapcp.delete_RevBool 2975 2976# Register RevBool in _pywrapcp: 2977_pywrapcp.RevBool_swigregister(RevBool) 2978 2979class IntVarContainer(object): 2980 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2981 2982 def __init__(self, *args, **kwargs): 2983 raise AttributeError("No constructor defined") 2984 __repr__ = _swig_repr 2985 2986 def Contains(self, var: "IntVar") -> "bool": 2987 return _pywrapcp.IntVarContainer_Contains(self, var) 2988 2989 def Element(self, index: "int") -> "operations_research::IntVarElement *": 2990 return _pywrapcp.IntVarContainer_Element(self, index) 2991 2992 def Size(self) -> "int": 2993 return _pywrapcp.IntVarContainer_Size(self) 2994 2995 def Store(self) -> "void": 2996 return _pywrapcp.IntVarContainer_Store(self) 2997 2998 def Restore(self) -> "void": 2999 return _pywrapcp.IntVarContainer_Restore(self) 3000 3001 def __eq__(self, container: "IntVarContainer") -> "bool": 3002 r""" Returns true if this and 'container' both represent the same V* -> E map. Runs in linear time; requires that the == operator on the type E is well defined.""" 3003 return _pywrapcp.IntVarContainer___eq__(self, container) 3004 3005 def __ne__(self, container: "IntVarContainer") -> "bool": 3006 return _pywrapcp.IntVarContainer___ne__(self, container) 3007 __swig_destroy__ = _pywrapcp.delete_IntVarContainer 3008 3009# Register IntVarContainer in _pywrapcp: 3010_pywrapcp.IntVarContainer_swigregister(IntVarContainer) 3011 3012class IntervalVarContainer(object): 3013 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3014 3015 def __init__(self, *args, **kwargs): 3016 raise AttributeError("No constructor defined") 3017 __repr__ = _swig_repr 3018 3019 def Contains(self, var: "IntervalVar") -> "bool": 3020 return _pywrapcp.IntervalVarContainer_Contains(self, var) 3021 3022 def Element(self, index: "int") -> "operations_research::IntervalVarElement *": 3023 return _pywrapcp.IntervalVarContainer_Element(self, index) 3024 3025 def Size(self) -> "int": 3026 return _pywrapcp.IntervalVarContainer_Size(self) 3027 3028 def Store(self) -> "void": 3029 return _pywrapcp.IntervalVarContainer_Store(self) 3030 3031 def Restore(self) -> "void": 3032 return _pywrapcp.IntervalVarContainer_Restore(self) 3033 3034 def __eq__(self, container: "IntervalVarContainer") -> "bool": 3035 r""" Returns true if this and 'container' both represent the same V* -> E map. Runs in linear time; requires that the == operator on the type E is well defined.""" 3036 return _pywrapcp.IntervalVarContainer___eq__(self, container) 3037 3038 def __ne__(self, container: "IntervalVarContainer") -> "bool": 3039 return _pywrapcp.IntervalVarContainer___ne__(self, container) 3040 __swig_destroy__ = _pywrapcp.delete_IntervalVarContainer 3041 3042# Register IntervalVarContainer in _pywrapcp: 3043_pywrapcp.IntervalVarContainer_swigregister(IntervalVarContainer) 3044 3045class SequenceVarContainer(object): 3046 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3047 3048 def __init__(self, *args, **kwargs): 3049 raise AttributeError("No constructor defined") 3050 __repr__ = _swig_repr 3051 3052 def Contains(self, var: "SequenceVar") -> "bool": 3053 return _pywrapcp.SequenceVarContainer_Contains(self, var) 3054 3055 def Element(self, index: "int") -> "operations_research::SequenceVarElement *": 3056 return _pywrapcp.SequenceVarContainer_Element(self, index) 3057 3058 def Size(self) -> "int": 3059 return _pywrapcp.SequenceVarContainer_Size(self) 3060 3061 def Store(self) -> "void": 3062 return _pywrapcp.SequenceVarContainer_Store(self) 3063 3064 def Restore(self) -> "void": 3065 return _pywrapcp.SequenceVarContainer_Restore(self) 3066 3067 def __eq__(self, container: "SequenceVarContainer") -> "bool": 3068 r""" Returns true if this and 'container' both represent the same V* -> E map. Runs in linear time; requires that the == operator on the type E is well defined.""" 3069 return _pywrapcp.SequenceVarContainer___eq__(self, container) 3070 3071 def __ne__(self, container: "SequenceVarContainer") -> "bool": 3072 return _pywrapcp.SequenceVarContainer___ne__(self, container) 3073 __swig_destroy__ = _pywrapcp.delete_SequenceVarContainer 3074 3075# Register SequenceVarContainer in _pywrapcp: 3076_pywrapcp.SequenceVarContainer_swigregister(SequenceVarContainer) 3077 3078class LocalSearchOperator(BaseObject): 3079 r""" This class represent a reversible FIFO structure. The main difference w.r.t a standard FIFO structure is that a Solver is given as parameter to the modifiers such that the solver can store the backtrack information Iterator's traversing order should not be changed, as some algorithm depend on it to be consistent. It's main use is to store a list of demons in the various classes of variables. The base class for all local search operators. A local search operator is an object that defines the neighborhood of a solution. In other words, a neighborhood is the set of solutions which can be reached from a given solution using an operator. The behavior of the LocalSearchOperator class is similar to iterators. The operator is synchronized with an assignment (gives the current values of the variables); this is done in the Start() method. Then one can iterate over the neighbors using the MakeNextNeighbor method. This method returns an assignment which represents the incremental changes to the current solution. It also returns a second assignment representing the changes to the last solution defined by the neighborhood operator; this assignment is empty if the neighborhood operator cannot track this information.""" 3080 3081 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3082 3083 def __init__(self, *args, **kwargs): 3084 raise AttributeError("No constructor defined - class is abstract") 3085 __repr__ = _swig_repr 3086 3087 def NextNeighbor(self, delta: "Assignment", deltadelta: "Assignment") -> "bool": 3088 return _pywrapcp.LocalSearchOperator_NextNeighbor(self, delta, deltadelta) 3089 3090 def Start(self, assignment: "Assignment") -> "void": 3091 return _pywrapcp.LocalSearchOperator_Start(self, assignment) 3092 def __disown__(self): 3093 self.this.disown() 3094 _pywrapcp.disown_LocalSearchOperator(self) 3095 return weakref.proxy(self) 3096 3097# Register LocalSearchOperator in _pywrapcp: 3098_pywrapcp.LocalSearchOperator_swigregister(LocalSearchOperator) 3099 3100class IntVarLocalSearchOperatorTemplate(LocalSearchOperator): 3101 r""" Base operator class for operators manipulating variables.""" 3102 3103 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3104 3105 def __init__(self, *args, **kwargs): 3106 raise AttributeError("No constructor defined - class is abstract") 3107 __repr__ = _swig_repr 3108 3109 def Start(self, assignment: "Assignment") -> "void": 3110 r""" This method should not be overridden. Override OnStart() instead which is called before exiting this method.""" 3111 return _pywrapcp.IntVarLocalSearchOperatorTemplate_Start(self, assignment) 3112 3113 def IsIncremental(self) -> "bool": 3114 return _pywrapcp.IntVarLocalSearchOperatorTemplate_IsIncremental(self) 3115 3116 def Size(self) -> "int": 3117 return _pywrapcp.IntVarLocalSearchOperatorTemplate_Size(self) 3118 3119 def Value(self, index: "int64_t") -> "long const &": 3120 r""" Returns the value in the current assignment of the variable of given index.""" 3121 return _pywrapcp.IntVarLocalSearchOperatorTemplate_Value(self, index) 3122 3123 def OldValue(self, index: "int64_t") -> "long const &": 3124 return _pywrapcp.IntVarLocalSearchOperatorTemplate_OldValue(self, index) 3125 3126 def SetValue(self, index: "int64_t", value: "long const &") -> "void": 3127 return _pywrapcp.IntVarLocalSearchOperatorTemplate_SetValue(self, index, value) 3128 3129 def OnStart(self) -> "void": 3130 r""" Called by Start() after synchronizing the operator with the current assignment. Should be overridden instead of Start() to avoid calling VarLocalSearchOperator::Start explicitly.""" 3131 return _pywrapcp.IntVarLocalSearchOperatorTemplate_OnStart(self) 3132 3133# Register IntVarLocalSearchOperatorTemplate in _pywrapcp: 3134_pywrapcp.IntVarLocalSearchOperatorTemplate_swigregister(IntVarLocalSearchOperatorTemplate) 3135 3136class IntVarLocalSearchOperator(IntVarLocalSearchOperatorTemplate): 3137 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3138 __repr__ = _swig_repr 3139 3140 def __init__(self, *args): 3141 if self.__class__ == IntVarLocalSearchOperator: 3142 _self = None 3143 else: 3144 _self = self 3145 _pywrapcp.IntVarLocalSearchOperator_swiginit(self, _pywrapcp.new_IntVarLocalSearchOperator(_self, *args)) 3146 __swig_destroy__ = _pywrapcp.delete_IntVarLocalSearchOperator 3147 3148 def NextNeighbor(self, delta: "Assignment", deltadelta: "Assignment") -> "bool": 3149 r""" Redefines MakeNextNeighbor to export a simpler interface. The calls to ApplyChanges() and RevertChanges() are factored in this method, hiding both delta and deltadelta from subclasses which only need to override MakeOneNeighbor(). Therefore this method should not be overridden. Override MakeOneNeighbor() instead.""" 3150 return _pywrapcp.IntVarLocalSearchOperator_NextNeighbor(self, delta, deltadelta) 3151 3152 def OneNeighbor(self) -> "bool": 3153 r""" Creates a new neighbor. It returns false when the neighborhood is completely explored. MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.""" 3154 return _pywrapcp.IntVarLocalSearchOperator_OneNeighbor(self) 3155 def __disown__(self): 3156 self.this.disown() 3157 _pywrapcp.disown_IntVarLocalSearchOperator(self) 3158 return weakref.proxy(self) 3159 3160# Register IntVarLocalSearchOperator in _pywrapcp: 3161_pywrapcp.IntVarLocalSearchOperator_swigregister(IntVarLocalSearchOperator) 3162 3163class SequenceVarLocalSearchOperatorTemplate(LocalSearchOperator): 3164 r""" Base operator class for operators manipulating variables.""" 3165 3166 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3167 3168 def __init__(self, *args, **kwargs): 3169 raise AttributeError("No constructor defined - class is abstract") 3170 __repr__ = _swig_repr 3171 3172 def Start(self, assignment: "Assignment") -> "void": 3173 r""" This method should not be overridden. Override OnStart() instead which is called before exiting this method.""" 3174 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_Start(self, assignment) 3175 3176 def IsIncremental(self) -> "bool": 3177 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_IsIncremental(self) 3178 3179 def Size(self) -> "int": 3180 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_Size(self) 3181 3182 def Value(self, index: "int64_t") -> "std::vector< int > const &": 3183 r""" Returns the value in the current assignment of the variable of given index.""" 3184 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_Value(self, index) 3185 3186 def OldValue(self, index: "int64_t") -> "std::vector< int > const &": 3187 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_OldValue(self, index) 3188 3189 def SetValue(self, index: "int64_t", value: "std::vector< int > const &") -> "void": 3190 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_SetValue(self, index, value) 3191 3192 def OnStart(self) -> "void": 3193 r""" Called by Start() after synchronizing the operator with the current assignment. Should be overridden instead of Start() to avoid calling VarLocalSearchOperator::Start explicitly.""" 3194 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_OnStart(self) 3195 3196# Register SequenceVarLocalSearchOperatorTemplate in _pywrapcp: 3197_pywrapcp.SequenceVarLocalSearchOperatorTemplate_swigregister(SequenceVarLocalSearchOperatorTemplate) 3198 3199class SequenceVarLocalSearchOperator(SequenceVarLocalSearchOperatorTemplate): 3200 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3201 3202 def __init__(self, *args, **kwargs): 3203 raise AttributeError("No constructor defined - class is abstract") 3204 __repr__ = _swig_repr 3205 3206# Register SequenceVarLocalSearchOperator in _pywrapcp: 3207_pywrapcp.SequenceVarLocalSearchOperator_swigregister(SequenceVarLocalSearchOperator) 3208 3209class BaseLns(IntVarLocalSearchOperator): 3210 r""" This is the base class for building an Lns operator. An Lns fragment is a collection of variables which will be relaxed. Fragments are built with NextFragment(), which returns false if there are no more fragments to build. Optionally one can override InitFragments, which is called from LocalSearchOperator::Start to initialize fragment data. Here's a sample relaxing one variable at a time: class OneVarLns : public BaseLns { public: OneVarLns(const std::vector<IntVar*>& vars) : BaseLns(vars), index_(0) {} virtual ~OneVarLns() {} virtual void InitFragments() { index_ = 0; } virtual bool NextFragment() { const int size = Size(); if (index_ < size) { AppendToFragment(index_); ++index_; return true; } else { return false; } } private: int index_; };""" 3211 3212 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3213 __repr__ = _swig_repr 3214 3215 def __init__(self, vars: "std::vector< operations_research::IntVar * > const &"): 3216 if self.__class__ == BaseLns: 3217 _self = None 3218 else: 3219 _self = self 3220 _pywrapcp.BaseLns_swiginit(self, _pywrapcp.new_BaseLns(_self, vars)) 3221 __swig_destroy__ = _pywrapcp.delete_BaseLns 3222 3223 def InitFragments(self) -> "void": 3224 return _pywrapcp.BaseLns_InitFragments(self) 3225 3226 def NextFragment(self) -> "bool": 3227 return _pywrapcp.BaseLns_NextFragment(self) 3228 3229 def AppendToFragment(self, index: "int") -> "void": 3230 return _pywrapcp.BaseLns_AppendToFragment(self, index) 3231 3232 def FragmentSize(self) -> "int": 3233 return _pywrapcp.BaseLns_FragmentSize(self) 3234 3235 def __getitem__(self, index: "int") -> "int64_t": 3236 return _pywrapcp.BaseLns___getitem__(self, index) 3237 3238 def __len__(self) -> "int": 3239 return _pywrapcp.BaseLns___len__(self) 3240 def __disown__(self): 3241 self.this.disown() 3242 _pywrapcp.disown_BaseLns(self) 3243 return weakref.proxy(self) 3244 3245# Register BaseLns in _pywrapcp: 3246_pywrapcp.BaseLns_swigregister(BaseLns) 3247 3248class ChangeValue(IntVarLocalSearchOperator): 3249 r""" Defines operators which change the value of variables; each neighbor corresponds to *one* modified variable. Sub-classes have to define ModifyValue which determines what the new variable value is going to be (given the current value and the variable).""" 3250 3251 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3252 __repr__ = _swig_repr 3253 3254 def __init__(self, vars: "std::vector< operations_research::IntVar * > const &"): 3255 if self.__class__ == ChangeValue: 3256 _self = None 3257 else: 3258 _self = self 3259 _pywrapcp.ChangeValue_swiginit(self, _pywrapcp.new_ChangeValue(_self, vars)) 3260 __swig_destroy__ = _pywrapcp.delete_ChangeValue 3261 3262 def ModifyValue(self, index: "int64_t", value: "int64_t") -> "int64_t": 3263 return _pywrapcp.ChangeValue_ModifyValue(self, index, value) 3264 3265 def OneNeighbor(self) -> "bool": 3266 r""" This method should not be overridden. Override ModifyValue() instead.""" 3267 return _pywrapcp.ChangeValue_OneNeighbor(self) 3268 def __disown__(self): 3269 self.this.disown() 3270 _pywrapcp.disown_ChangeValue(self) 3271 return weakref.proxy(self) 3272 3273# Register ChangeValue in _pywrapcp: 3274_pywrapcp.ChangeValue_swigregister(ChangeValue) 3275 3276class PathOperator(IntVarLocalSearchOperator): 3277 r""" Base class of the local search operators dedicated to path modifications (a path is a set of nodes linked together by arcs). This family of neighborhoods supposes they are handling next variables representing the arcs (var[i] represents the node immediately after i on a path). Several services are provided: - arc manipulators (SetNext(), ReverseChain(), MoveChain()) - path inspectors (Next(), Prev(), IsPathEnd()) - path iterators: operators need a given number of nodes to define a neighbor; this class provides the iteration on a given number of (base) nodes which can be used to define a neighbor (through the BaseNode method) Subclasses only need to override MakeNeighbor to create neighbors using the services above (no direct manipulation of assignments).""" 3278 3279 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3280 3281 def __init__(self, *args, **kwargs): 3282 raise AttributeError("No constructor defined - class is abstract") 3283 __repr__ = _swig_repr 3284 3285 def Neighbor(self) -> "bool": 3286 return _pywrapcp.PathOperator_Neighbor(self) 3287 3288# Register PathOperator in _pywrapcp: 3289_pywrapcp.PathOperator_swigregister(PathOperator) 3290 3291class LocalSearchFilter(BaseObject): 3292 r""" Classes to which this template function can be applied to as of 04/2014. Usage: LocalSearchOperator* op = MakeLocalSearchOperator<Relocate>(...); class TwoOpt; class Relocate; class Exchange; class Cross; class MakeActiveOperator; class MakeInactiveOperator; class MakeChainInactiveOperator; class SwapActiveOperator; class ExtendedSwapActiveOperator; class MakeActiveAndRelocate; class RelocateAndMakeActiveOperator; class RelocateAndMakeInactiveOperator; Local Search Filters are used for fast neighbor pruning. Filtering a move is done in several phases: - in the Relax phase, filters determine which parts of their internals will be changed by the candidate, and modify intermediary State - in the Accept phase, filters check that the candidate is feasible, - if the Accept phase succeeds, the solver may decide to trigger a Synchronize phase that makes filters change their internal representation to the last candidate, - otherwise (Accept fails or the solver does not want to synchronize), a Revert phase makes filters erase any intermediary State generated by the Relax and Accept phases. A given filter has phases called with the following pattern: (Relax.Accept.Synchronize | Relax.Accept.Revert | Relax.Revert)*. Filters's Revert() is always called in the reverse order their Accept() was called, to allow late filters to use state done/undone by early filters' Accept()/Revert().""" 3293 3294 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3295 3296 def __init__(self, *args, **kwargs): 3297 raise AttributeError("No constructor defined - class is abstract") 3298 __repr__ = _swig_repr 3299 3300 def Accept(self, delta: "Assignment", deltadelta: "Assignment", objective_min: "int64_t", objective_max: "int64_t") -> "bool": 3301 r""" Accepts a "delta" given the assignment with which the filter has been synchronized; the delta holds the variables which have been modified and their new value. If the filter represents a part of the global objective, its contribution must be between objective_min and objective_max. Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1, for the assignment (a,1), (b,0), the delta (b,1) will be rejected but the delta (a,0) will be accepted. TODO(user): Remove arguments when there are no more need for those.""" 3302 return _pywrapcp.LocalSearchFilter_Accept(self, delta, deltadelta, objective_min, objective_max) 3303 3304 def IsIncremental(self) -> "bool": 3305 return _pywrapcp.LocalSearchFilter_IsIncremental(self) 3306 3307 def Synchronize(self, assignment: "Assignment", delta: "Assignment") -> "void": 3308 r""" Synchronizes the filter with the current solution, delta being the difference with the solution passed to the previous call to Synchronize() or IncrementalSynchronize(). 'delta' can be used to incrementally synchronizing the filter with the new solution by only considering the changes in delta.""" 3309 return _pywrapcp.LocalSearchFilter_Synchronize(self, assignment, delta) 3310 __swig_destroy__ = _pywrapcp.delete_LocalSearchFilter 3311 3312# Register LocalSearchFilter in _pywrapcp: 3313_pywrapcp.LocalSearchFilter_swigregister(LocalSearchFilter) 3314 3315class LocalSearchFilterManager(BaseObject): 3316 r""" Filter manager: when a move is made, filters are executed to decide whether the solution is feasible and compute parts of the new cost. This class schedules filter execution and composes costs as a sum.""" 3317 3318 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3319 __repr__ = _swig_repr 3320 3321 def DebugString(self) -> "std::string": 3322 return _pywrapcp.LocalSearchFilterManager_DebugString(self) 3323 3324 def __init__(self, *args): 3325 _pywrapcp.LocalSearchFilterManager_swiginit(self, _pywrapcp.new_LocalSearchFilterManager(*args)) 3326 3327 def Accept(self, monitor: "operations_research::LocalSearchMonitor *const", delta: "Assignment", deltadelta: "Assignment", objective_min: "int64_t", objective_max: "int64_t") -> "bool": 3328 r""" Returns true iff all filters return true, and the sum of their accepted objectives is between objective_min and objective_max. The monitor has its Begin/EndFiltering events triggered.""" 3329 return _pywrapcp.LocalSearchFilterManager_Accept(self, monitor, delta, deltadelta, objective_min, objective_max) 3330 3331 def Synchronize(self, assignment: "Assignment", delta: "Assignment") -> "void": 3332 r""" Synchronizes all filters to assignment.""" 3333 return _pywrapcp.LocalSearchFilterManager_Synchronize(self, assignment, delta) 3334 __swig_destroy__ = _pywrapcp.delete_LocalSearchFilterManager 3335 3336# Register LocalSearchFilterManager in _pywrapcp: 3337_pywrapcp.LocalSearchFilterManager_swigregister(LocalSearchFilterManager) 3338 3339class IntVarLocalSearchFilter(LocalSearchFilter): 3340 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3341 __repr__ = _swig_repr 3342 3343 def __init__(self, vars: "std::vector< operations_research::IntVar * > const &"): 3344 if self.__class__ == IntVarLocalSearchFilter: 3345 _self = None 3346 else: 3347 _self = self 3348 _pywrapcp.IntVarLocalSearchFilter_swiginit(self, _pywrapcp.new_IntVarLocalSearchFilter(_self, vars)) 3349 __swig_destroy__ = _pywrapcp.delete_IntVarLocalSearchFilter 3350 3351 def Synchronize(self, assignment: "Assignment", delta: "Assignment") -> "void": 3352 r""" This method should not be overridden. Override OnSynchronize() instead which is called before exiting this method.""" 3353 return _pywrapcp.IntVarLocalSearchFilter_Synchronize(self, assignment, delta) 3354 3355 def Size(self) -> "int": 3356 return _pywrapcp.IntVarLocalSearchFilter_Size(self) 3357 3358 def Value(self, index: "int") -> "int64_t": 3359 return _pywrapcp.IntVarLocalSearchFilter_Value(self, index) 3360 3361 def IndexFromVar(self, var: "IntVar") -> "int64_t": 3362 return _pywrapcp.IntVarLocalSearchFilter_IndexFromVar(self, var) 3363 def __disown__(self): 3364 self.this.disown() 3365 _pywrapcp.disown_IntVarLocalSearchFilter(self) 3366 return weakref.proxy(self) 3367 3368# Register IntVarLocalSearchFilter in _pywrapcp: 3369_pywrapcp.IntVarLocalSearchFilter_swigregister(IntVarLocalSearchFilter) 3370 3371class BooleanVar(IntVar): 3372 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3373 3374 def __init__(self, *args, **kwargs): 3375 raise AttributeError("No constructor defined - class is abstract") 3376 __repr__ = _swig_repr 3377 3378 def Min(self) -> "int64_t": 3379 return _pywrapcp.BooleanVar_Min(self) 3380 3381 def SetMin(self, m: "int64_t") -> "void": 3382 return _pywrapcp.BooleanVar_SetMin(self, m) 3383 3384 def Max(self) -> "int64_t": 3385 return _pywrapcp.BooleanVar_Max(self) 3386 3387 def SetMax(self, m: "int64_t") -> "void": 3388 return _pywrapcp.BooleanVar_SetMax(self, m) 3389 3390 def SetRange(self, mi: "int64_t", ma: "int64_t") -> "void": 3391 return _pywrapcp.BooleanVar_SetRange(self, mi, ma) 3392 3393 def Bound(self) -> "bool": 3394 return _pywrapcp.BooleanVar_Bound(self) 3395 3396 def Value(self) -> "int64_t": 3397 return _pywrapcp.BooleanVar_Value(self) 3398 3399 def RemoveValue(self, v: "int64_t") -> "void": 3400 return _pywrapcp.BooleanVar_RemoveValue(self, v) 3401 3402 def RemoveInterval(self, l: "int64_t", u: "int64_t") -> "void": 3403 return _pywrapcp.BooleanVar_RemoveInterval(self, l, u) 3404 3405 def WhenBound(self, d: "Demon") -> "void": 3406 return _pywrapcp.BooleanVar_WhenBound(self, d) 3407 3408 def WhenRange(self, d: "Demon") -> "void": 3409 return _pywrapcp.BooleanVar_WhenRange(self, d) 3410 3411 def WhenDomain(self, d: "Demon") -> "void": 3412 return _pywrapcp.BooleanVar_WhenDomain(self, d) 3413 3414 def Size(self) -> "uint64_t": 3415 return _pywrapcp.BooleanVar_Size(self) 3416 3417 def Contains(self, v: "int64_t") -> "bool": 3418 return _pywrapcp.BooleanVar_Contains(self, v) 3419 3420 def HoleIteratorAux(self, reversible: "bool") -> "operations_research::IntVarIterator *": 3421 return _pywrapcp.BooleanVar_HoleIteratorAux(self, reversible) 3422 3423 def DomainIteratorAux(self, reversible: "bool") -> "operations_research::IntVarIterator *": 3424 return _pywrapcp.BooleanVar_DomainIteratorAux(self, reversible) 3425 3426 def DebugString(self) -> "std::string": 3427 return _pywrapcp.BooleanVar_DebugString(self) 3428 3429# Register BooleanVar in _pywrapcp: 3430_pywrapcp.BooleanVar_swigregister(BooleanVar) 3431 3432 3433class PyDecision(Decision): 3434 3435 def __init__(self): 3436 Decision.__init__(self) 3437 3438 def ApplyWrapper(self, solver): 3439 try: 3440 self.Apply(solver) 3441 except Exception as e: 3442 if 'CP Solver fail' in str(e): 3443 solver.ShouldFail() 3444 else: 3445 raise 3446 3447 def RefuteWrapper(self, solver): 3448 try: 3449 self.Refute(solver) 3450 except Exception as e: 3451 if 'CP Solver fail' in str(e): 3452 solver.ShouldFail() 3453 else: 3454 raise 3455 3456 def DebugString(self): 3457 return "PyDecision" 3458 3459 3460class PyDecisionBuilder(DecisionBuilder): 3461 3462 def __init__(self): 3463 DecisionBuilder.__init__(self) 3464 3465 def NextWrapper(self, solver): 3466 try: 3467 return self.Next(solver) 3468 except Exception as e: 3469 if 'CP Solver fail' in str(e): 3470 return solver.FailDecision() 3471 else: 3472 raise 3473 3474 def DebugString(self): 3475 return "PyDecisionBuilder" 3476 3477 3478class PyDemon(Demon): 3479 3480 def RunWrapper(self, solver): 3481 try: 3482 self.Run(solver) 3483 except Exception as e: 3484 if 'CP Solver fail' in str(e): 3485 solver.ShouldFail() 3486 else: 3487 raise 3488 3489 def DebugString(self): 3490 return "PyDemon" 3491 3492 3493class PyConstraintDemon(PyDemon): 3494 3495 def __init__(self, ct, method, delayed, *args): 3496 PyDemon.__init__(self) 3497 self.__constraint = ct 3498 self.__method = method 3499 self.__delayed = delayed 3500 self.__args = args 3501 3502 def Run(self, solver): 3503 self.__method(self.__constraint, *self.__args) 3504 3505 def Priority(self): 3506 return Solver.DELAYED_PRIORITY if self.__delayed else Solver.NORMAL_PRIORITY 3507 3508 def DebugString(self): 3509 return 'PyConstraintDemon' 3510 3511 3512class PyConstraint(Constraint): 3513 3514 def __init__(self, solver): 3515 Constraint.__init__(self, solver) 3516 self.__demons = [] 3517 3518 def Demon(self, method, *args): 3519 demon = PyConstraintDemon(self, method, False, *args) 3520 self.__demons.append(demon) 3521 return demon 3522 3523 def DelayedDemon(self, method, *args): 3524 demon = PyConstraintDemon(self, method, True, *args) 3525 self.__demons.append(demon) 3526 return demon 3527 3528 def InitialPropagateDemon(self): 3529 return self.solver().ConstraintInitialPropagateCallback(self) 3530 3531 def DelayedInitialPropagateDemon(self): 3532 return self.solver().DelayedConstraintInitialPropagateCallback(self) 3533 3534 def InitialPropagateWrapper(self): 3535 try: 3536 self.InitialPropagate() 3537 except Exception as e: 3538 if 'CP Solver fail' in str(e): 3539 self.solver().ShouldFail() 3540 else: 3541 raise 3542 3543 def DebugString(self): 3544 return "PyConstraint" 3545 3546 3547 3548class RoutingIndexManager(object): 3549 r""" Manager for any NodeIndex <-> variable index conversion. The routing solver uses variable indices internally and through its API. These variable indices are tricky to manage directly because one Node can correspond to a multitude of variables, depending on the number of times they appear in the model, and if they're used as start and/or end points. This class aims to simplify variable index usage, allowing users to use NodeIndex instead. Usage: .cpp} auto starts_ends = ...; /// These are NodeIndex. RoutingIndexManager manager(10, 4, starts_ends); // 10 nodes, 4 vehicles. RoutingModel model(manager);""" 3550 3551 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3552 __repr__ = _swig_repr 3553 3554 def __init__(self, *args): 3555 _pywrapcp.RoutingIndexManager_swiginit(self, _pywrapcp.new_RoutingIndexManager(*args)) 3556 __swig_destroy__ = _pywrapcp.delete_RoutingIndexManager 3557 3558 def GetNumberOfNodes(self) -> "int": 3559 return _pywrapcp.RoutingIndexManager_GetNumberOfNodes(self) 3560 3561 def GetNumberOfVehicles(self) -> "int": 3562 return _pywrapcp.RoutingIndexManager_GetNumberOfVehicles(self) 3563 3564 def GetNumberOfIndices(self) -> "int": 3565 return _pywrapcp.RoutingIndexManager_GetNumberOfIndices(self) 3566 3567 def GetStartIndex(self, vehicle: "int") -> "int64_t": 3568 return _pywrapcp.RoutingIndexManager_GetStartIndex(self, vehicle) 3569 3570 def GetEndIndex(self, vehicle: "int") -> "int64_t": 3571 return _pywrapcp.RoutingIndexManager_GetEndIndex(self, vehicle) 3572 3573 def NodeToIndex(self, node: "operations_research::RoutingIndexManager::NodeIndex") -> "int64_t": 3574 return _pywrapcp.RoutingIndexManager_NodeToIndex(self, node) 3575 3576 def IndexToNode(self, index: "int64_t") -> "operations_research::RoutingIndexManager::NodeIndex": 3577 return _pywrapcp.RoutingIndexManager_IndexToNode(self, index) 3578 3579# Register RoutingIndexManager in _pywrapcp: 3580_pywrapcp.RoutingIndexManager_swigregister(RoutingIndexManager) 3581 3582 3583def DefaultRoutingModelParameters() -> "operations_research::RoutingModelParameters": 3584 return _pywrapcp.DefaultRoutingModelParameters() 3585 3586def DefaultRoutingSearchParameters() -> "operations_research::RoutingSearchParameters": 3587 return _pywrapcp.DefaultRoutingSearchParameters() 3588 3589def FindErrorInRoutingSearchParameters(search_parameters: "operations_research::RoutingSearchParameters const &") -> "std::string": 3590 r""" Returns an empty std::string if the routing search parameters are valid, and a non-empty, human readable error description if they're not.""" 3591 return _pywrapcp.FindErrorInRoutingSearchParameters(search_parameters) 3592BOOL_UNSPECIFIED = _pywrapcp.BOOL_UNSPECIFIED 3593BOOL_FALSE = _pywrapcp.BOOL_FALSE 3594BOOL_TRUE = _pywrapcp.BOOL_TRUE 3595class RoutingModel(object): 3596 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3597 __repr__ = _swig_repr 3598 ROUTING_NOT_SOLVED = _pywrapcp.RoutingModel_ROUTING_NOT_SOLVED 3599 r""" Problem not solved yet (before calling RoutingModel::Solve()).""" 3600 ROUTING_SUCCESS = _pywrapcp.RoutingModel_ROUTING_SUCCESS 3601 r""" Problem solved successfully after calling RoutingModel::Solve().""" 3602 ROUTING_FAIL = _pywrapcp.RoutingModel_ROUTING_FAIL 3603 r""" No solution found to the problem after calling RoutingModel::Solve().""" 3604 ROUTING_FAIL_TIMEOUT = _pywrapcp.RoutingModel_ROUTING_FAIL_TIMEOUT 3605 r""" Time limit reached before finding a solution with RoutingModel::Solve().""" 3606 ROUTING_INVALID = _pywrapcp.RoutingModel_ROUTING_INVALID 3607 r""" Model, model parameters or flags are not valid.""" 3608 ROUTING_INFEASIBLE = _pywrapcp.RoutingModel_ROUTING_INFEASIBLE 3609 r""" Problem proven to be infeasible.""" 3610 PICKUP_AND_DELIVERY_NO_ORDER = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_NO_ORDER 3611 r""" Any precedence is accepted.""" 3612 PICKUP_AND_DELIVERY_LIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_LIFO 3613 r""" Deliveries must be performed in reverse order of pickups.""" 3614 PICKUP_AND_DELIVERY_FIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_FIFO 3615 r""" Deliveries must be performed in the same order as pickups.""" 3616 3617 def __init__(self, *args): 3618 _pywrapcp.RoutingModel_swiginit(self, _pywrapcp.new_RoutingModel(*args)) 3619 __swig_destroy__ = _pywrapcp.delete_RoutingModel 3620 3621 def RegisterUnaryTransitVector(self, values: "std::vector< int64_t >") -> "int": 3622 r""" Registers 'callback' and returns its index.""" 3623 return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values) 3624 3625 def RegisterUnaryTransitCallback(self, callback: "operations_research::RoutingModel::TransitCallback1") -> "int": 3626 return _pywrapcp.RoutingModel_RegisterUnaryTransitCallback(self, callback) 3627 3628 def RegisterPositiveUnaryTransitCallback(self, callback: "operations_research::RoutingModel::TransitCallback1") -> "int": 3629 return _pywrapcp.RoutingModel_RegisterPositiveUnaryTransitCallback(self, callback) 3630 3631 def RegisterTransitMatrix(self, values: "std::vector< std::vector< int64_t > >") -> "int": 3632 return _pywrapcp.RoutingModel_RegisterTransitMatrix(self, values) 3633 3634 def RegisterTransitCallback(self, callback: "operations_research::RoutingModel::TransitCallback2") -> "int": 3635 return _pywrapcp.RoutingModel_RegisterTransitCallback(self, callback) 3636 3637 def RegisterPositiveTransitCallback(self, callback: "operations_research::RoutingModel::TransitCallback2") -> "int": 3638 return _pywrapcp.RoutingModel_RegisterPositiveTransitCallback(self, callback) 3639 3640 def TransitCallback(self, callback_index: "int") -> "operations_research::RoutingModel::TransitCallback2 const &": 3641 return _pywrapcp.RoutingModel_TransitCallback(self, callback_index) 3642 3643 def UnaryTransitCallbackOrNull(self, callback_index: "int") -> "operations_research::RoutingModel::TransitCallback1 const &": 3644 return _pywrapcp.RoutingModel_UnaryTransitCallbackOrNull(self, callback_index) 3645 3646 def AddDimension(self, evaluator_index: "int", slack_max: "int64_t", capacity: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "bool": 3647 r""" Model creation Methods to add dimensions to routes; dimensions represent quantities accumulated at nodes along the routes. They represent quantities such as weights or volumes carried along the route, or distance or times. Quantities at a node are represented by "cumul" variables and the increase or decrease of quantities between nodes are represented by "transit" variables. These variables are linked as follows: if j == next(i), cumul(j) = cumul(i) + transit(i) + slack(i) where slack is a positive slack variable (can represent waiting times for a time dimension). Setting the value of fix_start_cumul_to_zero to true will force the "cumul" variable of the start node of all vehicles to be equal to 0. Creates a dimension where the transit variable is constrained to be equal to evaluator(i, next(i)); 'slack_max' is the upper bound of the slack variable and 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns false if a dimension with the same name has already been created (and doesn't create the new dimension). Takes ownership of the callback 'evaluator'.""" 3648 return _pywrapcp.RoutingModel_AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name) 3649 3650 def AddDimensionWithVehicleTransits(self, evaluator_indices: "std::vector< int > const &", slack_max: "int64_t", capacity: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "bool": 3651 return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name) 3652 3653 def AddDimensionWithVehicleCapacity(self, evaluator_index: "int", slack_max: "int64_t", vehicle_capacities: "std::vector< int64_t >", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "bool": 3654 return _pywrapcp.RoutingModel_AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name) 3655 3656 def AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices: "std::vector< int > const &", slack_max: "int64_t", vehicle_capacities: "std::vector< int64_t >", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "bool": 3657 return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name) 3658 3659 def AddConstantDimensionWithSlack(self, value: "int64_t", capacity: "int64_t", slack_max: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >": 3660 r""" Creates a dimension where the transit variable is constrained to be equal to 'value'; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered unary transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).""" 3661 return _pywrapcp.RoutingModel_AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name) 3662 3663 def AddConstantDimension(self, value: "int64_t", capacity: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >": 3664 return _pywrapcp.RoutingModel_AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name) 3665 3666 def AddVectorDimension(self, values: "std::vector< int64_t >", capacity: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >": 3667 r""" Creates a dimension where the transit variable is constrained to be equal to 'values[i]' for node i; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered unary transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).""" 3668 return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name) 3669 3670 def AddMatrixDimension(self, values: "std::vector< std::vector< int64_t > >", capacity: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >": 3671 r""" Creates a dimension where the transit variable is constrained to be equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).""" 3672 return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name) 3673 3674 def MakePathSpansAndTotalSlacks(self, dimension: "RoutingDimension", spans: "std::vector< operations_research::IntVar * >", total_slacks: "std::vector< operations_research::IntVar * >") -> "operations_research::Constraint *": 3675 r""" For every vehicle of the routing model: - if total_slacks[vehicle] is not nullptr, constrains it to be the sum of slacks on that vehicle, that is, dimension->CumulVar(end) - dimension->CumulVar(start) - sum_{node in path of vehicle} dimension->FixedTransitVar(node). - if spans[vehicle] is not nullptr, constrains it to be dimension->CumulVar(end) - dimension->CumulVar(start) This does stronger propagation than a decomposition, and takes breaks into account.""" 3676 return _pywrapcp.RoutingModel_MakePathSpansAndTotalSlacks(self, dimension, spans, total_slacks) 3677 3678 def GetAllDimensionNames(self) -> "std::vector< std::string >": 3679 r""" Outputs the names of all dimensions added to the routing engine.""" 3680 return _pywrapcp.RoutingModel_GetAllDimensionNames(self) 3681 3682 def GetDimensions(self) -> "std::vector< operations_research::RoutingDimension * > const &": 3683 r""" Returns all dimensions of the model.""" 3684 return _pywrapcp.RoutingModel_GetDimensions(self) 3685 3686 def GetDimensionsWithSoftOrSpanCosts(self) -> "std::vector< operations_research::RoutingDimension * >": 3687 r""" Returns dimensions with soft or vehicle span costs.""" 3688 return _pywrapcp.RoutingModel_GetDimensionsWithSoftOrSpanCosts(self) 3689 3690 def GetDimensionsWithGlobalCumulOptimizers(self) -> "std::vector< operations_research::RoutingDimension const * >": 3691 r""" Returns the dimensions which have [global|local]_dimension_optimizers_.""" 3692 return _pywrapcp.RoutingModel_GetDimensionsWithGlobalCumulOptimizers(self) 3693 3694 def GetDimensionsWithLocalCumulOptimizers(self) -> "std::vector< operations_research::RoutingDimension const * >": 3695 return _pywrapcp.RoutingModel_GetDimensionsWithLocalCumulOptimizers(self) 3696 3697 def HasGlobalCumulOptimizer(self, dimension: "RoutingDimension") -> "bool": 3698 r""" Returns whether the given dimension has global/local cumul optimizers.""" 3699 return _pywrapcp.RoutingModel_HasGlobalCumulOptimizer(self, dimension) 3700 3701 def HasLocalCumulOptimizer(self, dimension: "RoutingDimension") -> "bool": 3702 return _pywrapcp.RoutingModel_HasLocalCumulOptimizer(self, dimension) 3703 3704 def GetMutableGlobalCumulLPOptimizer(self, dimension: "RoutingDimension") -> "operations_research::GlobalDimensionCumulOptimizer *": 3705 r""" Returns the global/local dimension cumul optimizer for a given dimension, or nullptr if there is none.""" 3706 return _pywrapcp.RoutingModel_GetMutableGlobalCumulLPOptimizer(self, dimension) 3707 3708 def GetMutableGlobalCumulMPOptimizer(self, dimension: "RoutingDimension") -> "operations_research::GlobalDimensionCumulOptimizer *": 3709 return _pywrapcp.RoutingModel_GetMutableGlobalCumulMPOptimizer(self, dimension) 3710 3711 def GetMutableLocalCumulLPOptimizer(self, dimension: "RoutingDimension") -> "operations_research::LocalDimensionCumulOptimizer *": 3712 return _pywrapcp.RoutingModel_GetMutableLocalCumulLPOptimizer(self, dimension) 3713 3714 def GetMutableLocalCumulMPOptimizer(self, dimension: "RoutingDimension") -> "operations_research::LocalDimensionCumulOptimizer *": 3715 return _pywrapcp.RoutingModel_GetMutableLocalCumulMPOptimizer(self, dimension) 3716 3717 def HasDimension(self, dimension_name: "std::string const &") -> "bool": 3718 r""" Returns true if a dimension exists for a given dimension name.""" 3719 return _pywrapcp.RoutingModel_HasDimension(self, dimension_name) 3720 3721 def GetDimensionOrDie(self, dimension_name: "std::string const &") -> "operations_research::RoutingDimension const &": 3722 r""" Returns a dimension from its name. Dies if the dimension does not exist.""" 3723 return _pywrapcp.RoutingModel_GetDimensionOrDie(self, dimension_name) 3724 3725 def GetMutableDimension(self, dimension_name: "std::string const &") -> "operations_research::RoutingDimension *": 3726 r""" Returns a dimension from its name. Returns nullptr if the dimension does not exist.""" 3727 return _pywrapcp.RoutingModel_GetMutableDimension(self, dimension_name) 3728 3729 def SetPrimaryConstrainedDimension(self, dimension_name: "std::string const &") -> "void": 3730 r""" Set the given dimension as "primary constrained". As of August 2013, this is only used by ArcIsMoreConstrainedThanArc(). "dimension" must be the name of an existing dimension, or be empty, in which case there will not be a primary dimension after this call.""" 3731 return _pywrapcp.RoutingModel_SetPrimaryConstrainedDimension(self, dimension_name) 3732 3733 def GetPrimaryConstrainedDimension(self) -> "std::string const &": 3734 r""" Get the primary constrained dimension, or an empty string if it is unset.""" 3735 return _pywrapcp.RoutingModel_GetPrimaryConstrainedDimension(self) 3736 3737 def AddResourceGroup(self) -> "int": 3738 r""" Adds a resource group to the routing model. Returns its index in resource_groups_.""" 3739 return _pywrapcp.RoutingModel_AddResourceGroup(self) 3740 3741 def GetResourceGroups(self) -> "std::vector< std::unique_ptr< operations_research::RoutingModel::ResourceGroup > > const &": 3742 return _pywrapcp.RoutingModel_GetResourceGroups(self) 3743 3744 def GetResourceGroup(self, rg_index: "int") -> "operations_research::RoutingModel::ResourceGroup *": 3745 return _pywrapcp.RoutingModel_GetResourceGroup(self, rg_index) 3746 3747 def GetDimensionResourceGroupIndices(self, dimension: "RoutingDimension") -> "std::vector< int > const &": 3748 r""" Returns the indices of resource groups for this dimension. This method can only be called after the model has been closed.""" 3749 return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndices(self, dimension) 3750 3751 def GetDimensionResourceGroupIndex(self, dimension: "RoutingDimension") -> "int": 3752 r""" Returns the index of the resource group attached to the dimension. DCHECKS that there's exactly one resource group for this dimension.""" 3753 return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndex(self, dimension) 3754 3755 def AddDisjunction(self, *args) -> "operations_research::RoutingModel::DisjunctionIndex": 3756 r""" Adds a disjunction constraint on the indices: exactly 'max_cardinality' of the indices are active. Start and end indices of any vehicle cannot be part of a disjunction. If a penalty is given, at most 'max_cardinality' of the indices can be active, and if less are active, 'penalty' is payed per inactive index. This is equivalent to adding the constraint: p + Sum(i)active[i] == max_cardinality where p is an integer variable, and the following cost to the cost function: p * penalty. 'penalty' must be positive to make the disjunction optional; a negative penalty will force 'max_cardinality' indices of the disjunction to be performed, and therefore p == 0. Note: passing a vector with a single index will model an optional index with a penalty cost if it is not visited.""" 3757 return _pywrapcp.RoutingModel_AddDisjunction(self, *args) 3758 3759 def GetDisjunctionIndices(self, index: "int64_t") -> "std::vector< operations_research::RoutingModel::DisjunctionIndex > const &": 3760 r""" Returns the indices of the disjunctions to which an index belongs.""" 3761 return _pywrapcp.RoutingModel_GetDisjunctionIndices(self, index) 3762 3763 def GetDisjunctionPenalty(self, index: "operations_research::RoutingModel::DisjunctionIndex") -> "int64_t": 3764 r""" Returns the penalty of the node disjunction of index 'index'.""" 3765 return _pywrapcp.RoutingModel_GetDisjunctionPenalty(self, index) 3766 3767 def GetDisjunctionMaxCardinality(self, index: "operations_research::RoutingModel::DisjunctionIndex") -> "int64_t": 3768 r""" Returns the maximum number of possible active nodes of the node disjunction of index 'index'.""" 3769 return _pywrapcp.RoutingModel_GetDisjunctionMaxCardinality(self, index) 3770 3771 def GetNumberOfDisjunctions(self) -> "int": 3772 r""" Returns the number of node disjunctions in the model.""" 3773 return _pywrapcp.RoutingModel_GetNumberOfDisjunctions(self) 3774 3775 def HasMandatoryDisjunctions(self) -> "bool": 3776 r""" Returns true if the model contains mandatory disjunctions (ones with kNoPenalty as penalty).""" 3777 return _pywrapcp.RoutingModel_HasMandatoryDisjunctions(self) 3778 3779 def HasMaxCardinalityConstrainedDisjunctions(self) -> "bool": 3780 r""" Returns true if the model contains at least one disjunction which is constrained by its max_cardinality.""" 3781 return _pywrapcp.RoutingModel_HasMaxCardinalityConstrainedDisjunctions(self) 3782 3783 def GetPerfectBinaryDisjunctions(self) -> "std::vector< std::pair< int64_t,int64_t > >": 3784 r""" Returns the list of all perfect binary disjunctions, as pairs of variable indices: a disjunction is "perfect" when its variables do not appear in any other disjunction. Each pair is sorted (lowest variable index first), and the output vector is also sorted (lowest pairs first).""" 3785 return _pywrapcp.RoutingModel_GetPerfectBinaryDisjunctions(self) 3786 3787 def IgnoreDisjunctionsAlreadyForcedToZero(self) -> "void": 3788 r""" SPECIAL: Makes the solver ignore all the disjunctions whose active variables are all trivially zero (i.e. Max() == 0), by setting their max_cardinality to 0. This can be useful when using the BaseBinaryDisjunctionNeighborhood operators, in the context of arc-based routing.""" 3789 return _pywrapcp.RoutingModel_IgnoreDisjunctionsAlreadyForcedToZero(self) 3790 3791 def AddSoftSameVehicleConstraint(self, indices: "std::vector< int64_t > const &", cost: "int64_t") -> "void": 3792 r""" Adds a soft constraint to force a set of variable indices to be on the same vehicle. If all nodes are not on the same vehicle, each extra vehicle used adds 'cost' to the cost function.""" 3793 return _pywrapcp.RoutingModel_AddSoftSameVehicleConstraint(self, indices, cost) 3794 3795 def SetAllowedVehiclesForIndex(self, vehicles: "std::vector< int > const &", index: "int64_t") -> "void": 3796 r""" Sets the vehicles which can visit a given node. If the node is in a disjunction, this will not prevent it from being unperformed. Specifying an empty vector of vehicles has no effect (all vehicles will be allowed to visit the node).""" 3797 return _pywrapcp.RoutingModel_SetAllowedVehiclesForIndex(self, vehicles, index) 3798 3799 def IsVehicleAllowedForIndex(self, vehicle: "int", index: "int64_t") -> "bool": 3800 r""" Returns true if a vehicle is allowed to visit a given node.""" 3801 return _pywrapcp.RoutingModel_IsVehicleAllowedForIndex(self, vehicle, index) 3802 3803 def AddPickupAndDelivery(self, pickup: "int64_t", delivery: "int64_t") -> "void": 3804 r""" Notifies that index1 and index2 form a pair of nodes which should belong to the same route. This methods helps the search find better solutions, especially in the local search phase. It should be called each time you have an equality constraint linking the vehicle variables of two node (including for instance pickup and delivery problems): Solver* const solver = routing.solver(); int64_t index1 = manager.NodeToIndex(node1); int64_t index2 = manager.NodeToIndex(node2); solver->AddConstraint(solver->MakeEquality( routing.VehicleVar(index1), routing.VehicleVar(index2))); routing.AddPickupAndDelivery(index1, index2);""" 3805 return _pywrapcp.RoutingModel_AddPickupAndDelivery(self, pickup, delivery) 3806 3807 def AddPickupAndDeliverySets(self, pickup_disjunction: "operations_research::RoutingModel::DisjunctionIndex", delivery_disjunction: "operations_research::RoutingModel::DisjunctionIndex") -> "void": 3808 r""" Same as AddPickupAndDelivery but notifying that the performed node from the disjunction of index 'pickup_disjunction' is on the same route as the performed node from the disjunction of index 'delivery_disjunction'.""" 3809 return _pywrapcp.RoutingModel_AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction) 3810 3811 def GetPickupIndexPairs(self, node_index: "int64_t") -> "std::vector< std::pair< int,int > > const &": 3812 r""" Returns pairs for which the node is a pickup; the first element of each pair is the index in the pickup and delivery pairs list in which the pickup appears, the second element is its index in the pickups list.""" 3813 return _pywrapcp.RoutingModel_GetPickupIndexPairs(self, node_index) 3814 3815 def GetDeliveryIndexPairs(self, node_index: "int64_t") -> "std::vector< std::pair< int,int > > const &": 3816 r""" Same as above for deliveries.""" 3817 return _pywrapcp.RoutingModel_GetDeliveryIndexPairs(self, node_index) 3818 3819 def SetPickupAndDeliveryPolicyOfAllVehicles(self, policy: "operations_research::RoutingModel::PickupAndDeliveryPolicy") -> "void": 3820 r""" Sets the Pickup and delivery policy of all vehicles. It is equivalent to calling SetPickupAndDeliveryPolicyOfVehicle on all vehicles.""" 3821 return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfAllVehicles(self, policy) 3822 3823 def SetPickupAndDeliveryPolicyOfVehicle(self, policy: "operations_research::RoutingModel::PickupAndDeliveryPolicy", vehicle: "int") -> "void": 3824 return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle) 3825 3826 def GetPickupAndDeliveryPolicyOfVehicle(self, vehicle: "int") -> "operations_research::RoutingModel::PickupAndDeliveryPolicy": 3827 return _pywrapcp.RoutingModel_GetPickupAndDeliveryPolicyOfVehicle(self, vehicle) 3828 3829 def GetNumOfSingletonNodes(self) -> "int": 3830 r""" Returns the number of non-start/end nodes which do not appear in a pickup/delivery pair.""" 3831 return _pywrapcp.RoutingModel_GetNumOfSingletonNodes(self) 3832 TYPE_ADDED_TO_VEHICLE = _pywrapcp.RoutingModel_TYPE_ADDED_TO_VEHICLE 3833 r""" When visited, the number of types 'T' on the vehicle increases by one.""" 3834 ADDED_TYPE_REMOVED_FROM_VEHICLE = _pywrapcp.RoutingModel_ADDED_TYPE_REMOVED_FROM_VEHICLE 3835 r""" When visited, one instance of type 'T' previously added to the route (TYPE_ADDED_TO_VEHICLE), if any, is removed from the vehicle. If the type was not previously added to the route or all added instances have already been removed, this visit has no effect on the types.""" 3836 TYPE_ON_VEHICLE_UP_TO_VISIT = _pywrapcp.RoutingModel_TYPE_ON_VEHICLE_UP_TO_VISIT 3837 r""" With the following policy, the visit enforces that type 'T' is considered on the route from its start until this node is visited.""" 3838 TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED = _pywrapcp.RoutingModel_TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED 3839 r""" The visit doesn't have an impact on the number of types 'T' on the route, as it's (virtually) added and removed directly. This policy can be used for visits which are part of an incompatibility or requirement set without affecting the type count on the route.""" 3840 3841 def SetVisitType(self, index: "int64_t", type: "int", type_policy: "operations_research::RoutingModel::VisitTypePolicy") -> "void": 3842 return _pywrapcp.RoutingModel_SetVisitType(self, index, type, type_policy) 3843 3844 def GetVisitType(self, index: "int64_t") -> "int": 3845 return _pywrapcp.RoutingModel_GetVisitType(self, index) 3846 3847 def GetSingleNodesOfType(self, type: "int") -> "std::vector< int > const &": 3848 return _pywrapcp.RoutingModel_GetSingleNodesOfType(self, type) 3849 3850 def GetPairIndicesOfType(self, type: "int") -> "std::vector< int > const &": 3851 return _pywrapcp.RoutingModel_GetPairIndicesOfType(self, type) 3852 3853 def GetVisitTypePolicy(self, index: "int64_t") -> "operations_research::RoutingModel::VisitTypePolicy": 3854 return _pywrapcp.RoutingModel_GetVisitTypePolicy(self, index) 3855 3856 def CloseVisitTypes(self) -> "void": 3857 r""" This function should be called once all node visit types have been set and prior to adding any incompatibilities/requirements. "close" types.""" 3858 return _pywrapcp.RoutingModel_CloseVisitTypes(self) 3859 3860 def GetNumberOfVisitTypes(self) -> "int": 3861 return _pywrapcp.RoutingModel_GetNumberOfVisitTypes(self) 3862 3863 def AddHardTypeIncompatibility(self, type1: "int", type2: "int") -> "void": 3864 r""" Incompatibilities: Two nodes with "hard" incompatible types cannot share the same route at all, while with a "temporal" incompatibility they can't be on the same route at the same time.""" 3865 return _pywrapcp.RoutingModel_AddHardTypeIncompatibility(self, type1, type2) 3866 3867 def AddTemporalTypeIncompatibility(self, type1: "int", type2: "int") -> "void": 3868 return _pywrapcp.RoutingModel_AddTemporalTypeIncompatibility(self, type1, type2) 3869 3870 def GetHardTypeIncompatibilitiesOfType(self, type: "int") -> "absl::flat_hash_set< int > const &": 3871 r""" Returns visit types incompatible with a given type.""" 3872 return _pywrapcp.RoutingModel_GetHardTypeIncompatibilitiesOfType(self, type) 3873 3874 def GetTemporalTypeIncompatibilitiesOfType(self, type: "int") -> "absl::flat_hash_set< int > const &": 3875 return _pywrapcp.RoutingModel_GetTemporalTypeIncompatibilitiesOfType(self, type) 3876 3877 def HasHardTypeIncompatibilities(self) -> "bool": 3878 r""" Returns true iff any hard (resp. temporal) type incompatibilities have been added to the model.""" 3879 return _pywrapcp.RoutingModel_HasHardTypeIncompatibilities(self) 3880 3881 def HasTemporalTypeIncompatibilities(self) -> "bool": 3882 return _pywrapcp.RoutingModel_HasTemporalTypeIncompatibilities(self) 3883 3884 def AddSameVehicleRequiredTypeAlternatives(self, dependent_type: "int", required_type_alternatives: "absl::flat_hash_set< int >") -> "void": 3885 r""" Requirements: NOTE: As of 2019-04, cycles in the requirement graph are not supported, and lead to the dependent nodes being skipped if possible (otherwise the model is considered infeasible). The following functions specify that "dependent_type" requires at least one of the types in "required_type_alternatives". For same-vehicle requirements, a node of dependent type type_D requires at least one node of type type_R among the required alternatives on the same route.""" 3886 return _pywrapcp.RoutingModel_AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives) 3887 3888 def AddRequiredTypeAlternativesWhenAddingType(self, dependent_type: "int", required_type_alternatives: "absl::flat_hash_set< int >") -> "void": 3889 r""" If type_D depends on type_R when adding type_D, any node_D of type_D and VisitTypePolicy TYPE_ADDED_TO_VEHICLE or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED requires at least one type_R on its vehicle at the time node_D is visited.""" 3890 return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives) 3891 3892 def AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type: "int", required_type_alternatives: "absl::flat_hash_set< int >") -> "void": 3893 r""" The following requirements apply when visiting dependent nodes that remove their type from the route, i.e. type_R must be on the vehicle when type_D of VisitTypePolicy ADDED_TYPE_REMOVED_FROM_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED is visited.""" 3894 return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives) 3895 3896 def GetSameVehicleRequiredTypeAlternativesOfType(self, type: "int") -> "std::vector< absl::flat_hash_set< int > > const &": 3897 r""" Returns the set of same-vehicle requirement alternatives for the given type.""" 3898 return _pywrapcp.RoutingModel_GetSameVehicleRequiredTypeAlternativesOfType(self, type) 3899 3900 def GetRequiredTypeAlternativesWhenAddingType(self, type: "int") -> "std::vector< absl::flat_hash_set< int > > const &": 3901 r""" Returns the set of requirement alternatives when adding the given type.""" 3902 return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenAddingType(self, type) 3903 3904 def GetRequiredTypeAlternativesWhenRemovingType(self, type: "int") -> "std::vector< absl::flat_hash_set< int > > const &": 3905 r""" Returns the set of requirement alternatives when removing the given type.""" 3906 return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenRemovingType(self, type) 3907 3908 def HasSameVehicleTypeRequirements(self) -> "bool": 3909 r""" Returns true iff any same-route (resp. temporal) type requirements have been added to the model.""" 3910 return _pywrapcp.RoutingModel_HasSameVehicleTypeRequirements(self) 3911 3912 def HasTemporalTypeRequirements(self) -> "bool": 3913 return _pywrapcp.RoutingModel_HasTemporalTypeRequirements(self) 3914 3915 def HasTypeRegulations(self) -> "bool": 3916 r""" Returns true iff the model has any incompatibilities or requirements set on node types.""" 3917 return _pywrapcp.RoutingModel_HasTypeRegulations(self) 3918 3919 def UnperformedPenalty(self, var_index: "int64_t") -> "int64_t": 3920 r""" Get the "unperformed" penalty of a node. This is only well defined if the node is only part of a single Disjunction, and that disjunction has a penalty. For forced active nodes returns max int64_t. In all other cases, this returns 0.""" 3921 return _pywrapcp.RoutingModel_UnperformedPenalty(self, var_index) 3922 3923 def UnperformedPenaltyOrValue(self, default_value: "int64_t", var_index: "int64_t") -> "int64_t": 3924 r""" Same as above except that it returns default_value instead of 0 when penalty is not well defined (default value is passed as first argument to simplify the usage of the method in a callback).""" 3925 return _pywrapcp.RoutingModel_UnperformedPenaltyOrValue(self, default_value, var_index) 3926 3927 def GetDepot(self) -> "int64_t": 3928 r""" Returns the variable index of the first starting or ending node of all routes. If all routes start and end at the same node (single depot), this is the node returned.""" 3929 return _pywrapcp.RoutingModel_GetDepot(self) 3930 3931 def SetMaximumNumberOfActiveVehicles(self, max_active_vehicles: "int") -> "void": 3932 r""" Constrains the maximum number of active vehicles, aka the number of vehicles which do not have an empty route. For instance, this can be used to limit the number of routes in the case where there are fewer drivers than vehicles and that the fleet of vehicle is heterogeneous.""" 3933 return _pywrapcp.RoutingModel_SetMaximumNumberOfActiveVehicles(self, max_active_vehicles) 3934 3935 def GetMaximumNumberOfActiveVehicles(self) -> "int": 3936 r""" Returns the maximum number of active vehicles.""" 3937 return _pywrapcp.RoutingModel_GetMaximumNumberOfActiveVehicles(self) 3938 3939 def SetArcCostEvaluatorOfAllVehicles(self, evaluator_index: "int") -> "void": 3940 r""" Sets the cost function of the model such that the cost of a segment of a route between node 'from' and 'to' is evaluator(from, to), whatever the route or vehicle performing the route.""" 3941 return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfAllVehicles(self, evaluator_index) 3942 3943 def SetArcCostEvaluatorOfVehicle(self, evaluator_index: "int", vehicle: "int") -> "void": 3944 r""" Sets the cost function for a given vehicle route.""" 3945 return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle) 3946 3947 def SetFixedCostOfAllVehicles(self, cost: "int64_t") -> "void": 3948 r""" Sets the fixed cost of all vehicle routes. It is equivalent to calling SetFixedCostOfVehicle on all vehicle routes.""" 3949 return _pywrapcp.RoutingModel_SetFixedCostOfAllVehicles(self, cost) 3950 3951 def SetFixedCostOfVehicle(self, cost: "int64_t", vehicle: "int") -> "void": 3952 r""" Sets the fixed cost of one vehicle route.""" 3953 return _pywrapcp.RoutingModel_SetFixedCostOfVehicle(self, cost, vehicle) 3954 3955 def GetFixedCostOfVehicle(self, vehicle: "int") -> "int64_t": 3956 r""" Returns the route fixed cost taken into account if the route of the vehicle is not empty, aka there's at least one node on the route other than the first and last nodes.""" 3957 return _pywrapcp.RoutingModel_GetFixedCostOfVehicle(self, vehicle) 3958 3959 def SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor: "int64_t", quadratic_cost_factor: "int64_t") -> "void": 3960 r""" The following methods set the linear and quadratic cost factors of vehicles (must be positive values). The default value of these parameters is zero for all vehicles. When set, the cost_ of the model will contain terms aiming at reducing the number of vehicles used in the model, by adding the following to the objective for every vehicle v: INDICATOR(v used in the model) * [linear_cost_factor_of_vehicle_[v] - quadratic_cost_factor_of_vehicle_[v]*(square of length of route v)] i.e. for every used vehicle, we add the linear factor as fixed cost, and subtract the square of the route length multiplied by the quadratic factor. This second term aims at making the routes as dense as possible. Sets the linear and quadratic cost factor of all vehicles.""" 3961 return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor) 3962 3963 def SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor: "int64_t", quadratic_cost_factor: "int64_t", vehicle: "int") -> "void": 3964 r""" Sets the linear and quadratic cost factor of the given vehicle.""" 3965 return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle) 3966 3967 def GetAmortizedLinearCostFactorOfVehicles(self) -> "std::vector< int64_t > const &": 3968 return _pywrapcp.RoutingModel_GetAmortizedLinearCostFactorOfVehicles(self) 3969 3970 def GetAmortizedQuadraticCostFactorOfVehicles(self) -> "std::vector< int64_t > const &": 3971 return _pywrapcp.RoutingModel_GetAmortizedQuadraticCostFactorOfVehicles(self) 3972 3973 def SetVehicleUsedWhenEmpty(self, is_used: "bool", vehicle: "int") -> "void": 3974 return _pywrapcp.RoutingModel_SetVehicleUsedWhenEmpty(self, is_used, vehicle) 3975 3976 def IsVehicleUsedWhenEmpty(self, vehicle: "int") -> "bool": 3977 return _pywrapcp.RoutingModel_IsVehicleUsedWhenEmpty(self, vehicle) 3978 3979 def SetFirstSolutionEvaluator(self, evaluator: "operations_research::Solver::IndexEvaluator2") -> "void": 3980 r""" Gets/sets the evaluator used during the search. Only relevant when RoutingSearchParameters.first_solution_strategy = EVALUATOR_STRATEGY. Takes ownership of evaluator.""" 3981 return _pywrapcp.RoutingModel_SetFirstSolutionEvaluator(self, evaluator) 3982 3983 def AddLocalSearchOperator(self, ls_operator: "LocalSearchOperator") -> "void": 3984 r""" Adds a local search operator to the set of operators used to solve the vehicle routing problem.""" 3985 return _pywrapcp.RoutingModel_AddLocalSearchOperator(self, ls_operator) 3986 3987 def AddSearchMonitor(self, monitor: "SearchMonitor") -> "void": 3988 r""" Adds a search monitor to the search used to solve the routing model.""" 3989 return _pywrapcp.RoutingModel_AddSearchMonitor(self, monitor) 3990 3991 def AddAtSolutionCallback(self, callback: "std::function< void () >") -> "void": 3992 r""" Adds a callback called each time a solution is found during the search. This is a shortcut to creating a monitor to call the callback on AtSolution() and adding it with AddSearchMonitor.""" 3993 return _pywrapcp.RoutingModel_AddAtSolutionCallback(self, callback) 3994 3995 def AddVariableMinimizedByFinalizer(self, var: "IntVar") -> "void": 3996 r""" Adds a variable to minimize in the solution finalizer. The solution finalizer is called each time a solution is found during the search and allows to instantiate secondary variables (such as dimension cumul variables).""" 3997 return _pywrapcp.RoutingModel_AddVariableMinimizedByFinalizer(self, var) 3998 3999 def AddVariableMaximizedByFinalizer(self, var: "IntVar") -> "void": 4000 r""" Adds a variable to maximize in the solution finalizer (see above for information on the solution finalizer).""" 4001 return _pywrapcp.RoutingModel_AddVariableMaximizedByFinalizer(self, var) 4002 4003 def AddWeightedVariableMinimizedByFinalizer(self, var: "IntVar", cost: "int64_t") -> "void": 4004 r""" Adds a variable to minimize in the solution finalizer, with a weighted priority: the higher the more priority it has.""" 4005 return _pywrapcp.RoutingModel_AddWeightedVariableMinimizedByFinalizer(self, var, cost) 4006 4007 def AddWeightedVariableMaximizedByFinalizer(self, var: "IntVar", cost: "int64_t") -> "void": 4008 r""" Adds a variable to maximize in the solution finalizer, with a weighted priority: the higher the more priority it has.""" 4009 return _pywrapcp.RoutingModel_AddWeightedVariableMaximizedByFinalizer(self, var, cost) 4010 4011 def AddVariableTargetToFinalizer(self, var: "IntVar", target: "int64_t") -> "void": 4012 r""" Add a variable to set the closest possible to the target value in the solution finalizer.""" 4013 return _pywrapcp.RoutingModel_AddVariableTargetToFinalizer(self, var, target) 4014 4015 def AddWeightedVariableTargetToFinalizer(self, var: "IntVar", target: "int64_t", cost: "int64_t") -> "void": 4016 r""" Same as above with a weighted priority: the higher the cost, the more priority it has to be set close to the target value.""" 4017 return _pywrapcp.RoutingModel_AddWeightedVariableTargetToFinalizer(self, var, target, cost) 4018 4019 def CloseModel(self) -> "void": 4020 r""" Closes the current routing model; after this method is called, no modification to the model can be done, but RoutesToAssignment becomes available. Note that CloseModel() is automatically called by Solve() and other methods that produce solution. This is equivalent to calling CloseModelWithParameters(DefaultRoutingSearchParameters()).""" 4021 return _pywrapcp.RoutingModel_CloseModel(self) 4022 4023 def CloseModelWithParameters(self, search_parameters: "operations_research::RoutingSearchParameters const &") -> "void": 4024 r""" Same as above taking search parameters (as of 10/2015 some the parameters have to be set when closing the model).""" 4025 return _pywrapcp.RoutingModel_CloseModelWithParameters(self, search_parameters) 4026 4027 def Solve(self, assignment: "Assignment"=None) -> "operations_research::Assignment const *": 4028 r""" Solves the current routing model; closes the current model. This is equivalent to calling SolveWithParameters(DefaultRoutingSearchParameters()) or SolveFromAssignmentWithParameters(assignment, DefaultRoutingSearchParameters()).""" 4029 return _pywrapcp.RoutingModel_Solve(self, assignment) 4030 4031 def SolveWithParameters(self, search_parameters: "operations_research::RoutingSearchParameters const &", solutions: "std::vector< operations_research::Assignment const * > *"=None) -> "operations_research::Assignment const *": 4032 r""" Solves the current routing model with the given parameters. If 'solutions' is specified, it will contain the k best solutions found during the search (from worst to best, including the one returned by this method), where k corresponds to the 'number_of_solutions_to_collect' in 'search_parameters'. Note that the Assignment returned by the method and the ones in solutions are owned by the underlying solver and should not be deleted.""" 4033 return _pywrapcp.RoutingModel_SolveWithParameters(self, search_parameters, solutions) 4034 4035 def SolveFromAssignmentWithParameters(self, assignment: "Assignment", search_parameters: "operations_research::RoutingSearchParameters const &", solutions: "std::vector< operations_research::Assignment const * > *"=None) -> "operations_research::Assignment const *": 4036 r""" Same as above, except that if assignment is not null, it will be used as the initial solution.""" 4037 return _pywrapcp.RoutingModel_SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions) 4038 4039 def SolveFromAssignmentsWithParameters(self, assignments: "std::vector< operations_research::Assignment const * > const &", search_parameters: "operations_research::RoutingSearchParameters const &", solutions: "std::vector< operations_research::Assignment const * > *"=None) -> "operations_research::Assignment const *": 4040 r""" Same as above but will try all assignments in order as first solutions until one succeeds.""" 4041 return _pywrapcp.RoutingModel_SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions) 4042 4043 def SetAssignmentFromOtherModelAssignment(self, target_assignment: "Assignment", source_model: "RoutingModel", source_assignment: "Assignment") -> "void": 4044 r""" Given a "source_model" and its "source_assignment", resets "target_assignment" with the IntVar variables (nexts_, and vehicle_vars_ if costs aren't homogeneous across vehicles) of "this" model, with the values set according to those in "other_assignment". The objective_element of target_assignment is set to this->cost_.""" 4045 return _pywrapcp.RoutingModel_SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment) 4046 4047 def ComputeLowerBound(self) -> "int64_t": 4048 r""" Computes a lower bound to the routing problem solving a linear assignment problem. The routing model must be closed before calling this method. Note that problems with node disjunction constraints (including optional nodes) and non-homogenous costs are not supported (the method returns 0 in these cases).""" 4049 return _pywrapcp.RoutingModel_ComputeLowerBound(self) 4050 4051 def status(self) -> "operations_research::RoutingModel::Status": 4052 r""" Returns the current status of the routing model.""" 4053 return _pywrapcp.RoutingModel_status(self) 4054 4055 def enable_deep_serialization(self) -> "bool": 4056 r""" Returns the value of the internal enable_deep_serialization_ parameter.""" 4057 return _pywrapcp.RoutingModel_enable_deep_serialization(self) 4058 4059 def ApplyLocks(self, locks: "std::vector< int64_t > const &") -> "operations_research::IntVar *": 4060 r""" Applies a lock chain to the next search. 'locks' represents an ordered vector of nodes representing a partial route which will be fixed during the next search; it will constrain next variables such that: next[locks[i]] == locks[i+1]. Returns the next variable at the end of the locked chain; this variable is not locked. An assignment containing the locks can be obtained by calling PreAssignment().""" 4061 return _pywrapcp.RoutingModel_ApplyLocks(self, locks) 4062 4063 def ApplyLocksToAllVehicles(self, locks: "std::vector< std::vector< int64_t > > const &", close_routes: "bool") -> "bool": 4064 r""" Applies lock chains to all vehicles to the next search, such that locks[p] is the lock chain for route p. Returns false if the locks do not contain valid routes; expects that the routes do not contain the depots, i.e. there are empty vectors in place of empty routes. If close_routes is set to true, adds the end nodes to the route of each vehicle and deactivates other nodes. An assignment containing the locks can be obtained by calling PreAssignment().""" 4065 return _pywrapcp.RoutingModel_ApplyLocksToAllVehicles(self, locks, close_routes) 4066 4067 def PreAssignment(self) -> "operations_research::Assignment const *const": 4068 r""" Returns an assignment used to fix some of the variables of the problem. In practice, this assignment locks partial routes of the problem. This can be used in the context of locking the parts of the routes which have already been driven in online routing problems.""" 4069 return _pywrapcp.RoutingModel_PreAssignment(self) 4070 4071 def MutablePreAssignment(self) -> "operations_research::Assignment *": 4072 return _pywrapcp.RoutingModel_MutablePreAssignment(self) 4073 4074 def WriteAssignment(self, file_name: "std::string const &") -> "bool": 4075 r""" Writes the current solution to a file containing an AssignmentProto. Returns false if the file cannot be opened or if there is no current solution.""" 4076 return _pywrapcp.RoutingModel_WriteAssignment(self, file_name) 4077 4078 def ReadAssignment(self, file_name: "std::string const &") -> "operations_research::Assignment *": 4079 r""" Reads an assignment from a file and returns the current solution. Returns nullptr if the file cannot be opened or if the assignment is not valid.""" 4080 return _pywrapcp.RoutingModel_ReadAssignment(self, file_name) 4081 4082 def RestoreAssignment(self, solution: "Assignment") -> "operations_research::Assignment *": 4083 r""" Restores an assignment as a solution in the routing model and returns the new solution. Returns nullptr if the assignment is not valid.""" 4084 return _pywrapcp.RoutingModel_RestoreAssignment(self, solution) 4085 4086 def ReadAssignmentFromRoutes(self, routes: "std::vector< std::vector< int64_t > > const &", ignore_inactive_indices: "bool") -> "operations_research::Assignment *": 4087 r""" Restores the routes as the current solution. Returns nullptr if the solution cannot be restored (routes do not contain a valid solution). Note that calling this method will run the solver to assign values to the dimension variables; this may take considerable amount of time, especially when using dimensions with slack.""" 4088 return _pywrapcp.RoutingModel_ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices) 4089 4090 def RoutesToAssignment(self, routes: "std::vector< std::vector< int64_t > > const &", ignore_inactive_indices: "bool", close_routes: "bool", assignment: "Assignment") -> "bool": 4091 r""" Fills an assignment from a specification of the routes of the vehicles. The routes are specified as lists of variable indices that appear on the routes of the vehicles. The indices of the outer vector in 'routes' correspond to vehicles IDs, the inner vector contains the variable indices on the routes for the given vehicle. The inner vectors must not contain the start and end indices, as these are determined by the routing model. Sets the value of NextVars in the assignment, adding the variables to the assignment if necessary. The method does not touch other variables in the assignment. The method can only be called after the model is closed. With ignore_inactive_indices set to false, this method will fail (return nullptr) in case some of the route contain indices that are deactivated in the model; when set to true, these indices will be skipped. Returns true if routes were successfully loaded. However, such assignment still might not be a valid solution to the routing problem due to more complex constraints; it is advisible to call solver()->CheckSolution() afterwards.""" 4092 return _pywrapcp.RoutingModel_RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment) 4093 4094 def AssignmentToRoutes(self, assignment: "Assignment", routes: "std::vector< std::vector< int64_t > > *const") -> "void": 4095 r""" Converts the solution in the given assignment to routes for all vehicles. Expects that assignment contains a valid solution (i.e. routes for all vehicles end with an end index for that vehicle).""" 4096 return _pywrapcp.RoutingModel_AssignmentToRoutes(self, assignment, routes) 4097 4098 def CompactAssignment(self, assignment: "Assignment") -> "operations_research::Assignment *": 4099 r""" Converts the solution in the given assignment to routes for all vehicles. If the returned vector is route_indices, route_indices[i][j] is the index for jth location visited on route i. Note that contrary to AssignmentToRoutes, the vectors do include start and end locations. Returns a compacted version of the given assignment, in which all vehicles with id lower or equal to some N have non-empty routes, and all vehicles with id greater than N have empty routes. Does not take ownership of the returned object. If found, the cost of the compact assignment is the same as in the original assignment and it preserves the values of 'active' variables. Returns nullptr if a compact assignment was not found. This method only works in homogenous mode, and it only swaps equivalent vehicles (vehicles with the same start and end nodes). When creating the compact assignment, the empty plan is replaced by the route assigned to the compatible vehicle with the highest id. Note that with more complex constraints on vehicle variables, this method might fail even if a compact solution exists. This method changes the vehicle and dimension variables as necessary. While compacting the solution, only basic checks on vehicle variables are performed; if one of these checks fails no attempts to repair it are made (instead, the method returns nullptr).""" 4100 return _pywrapcp.RoutingModel_CompactAssignment(self, assignment) 4101 4102 def CompactAndCheckAssignment(self, assignment: "Assignment") -> "operations_research::Assignment *": 4103 r""" Same as CompactAssignment() but also checks the validity of the final compact solution; if it is not valid, no attempts to repair it are made (instead, the method returns nullptr).""" 4104 return _pywrapcp.RoutingModel_CompactAndCheckAssignment(self, assignment) 4105 4106 def AddToAssignment(self, var: "IntVar") -> "void": 4107 r""" Adds an extra variable to the vehicle routing assignment.""" 4108 return _pywrapcp.RoutingModel_AddToAssignment(self, var) 4109 4110 def AddIntervalToAssignment(self, interval: "IntervalVar") -> "void": 4111 return _pywrapcp.RoutingModel_AddIntervalToAssignment(self, interval) 4112 4113 def PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment: "Assignment", duration_limit: "absl::Duration", time_limit_was_reached: "bool *"=None) -> "operations_research::Assignment const *": 4114 r""" For every dimension in the model with an optimizer in local/global_dimension_optimizers_, this method tries to pack the cumul values of the dimension, such that: - The cumul costs (span costs, soft lower and upper bound costs, etc) are minimized. - The cumuls of the ends of the routes are minimized for this given minimal cumul cost. - Given these minimal end cumuls, the route start cumuls are maximized. Returns the assignment resulting from allocating these packed cumuls with the solver, and nullptr if these cumuls could not be set by the solver.""" 4115 return _pywrapcp.RoutingModel_PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached) 4116 4117 def AddLocalSearchFilter(self, filter: "LocalSearchFilter") -> "void": 4118 r""" Adds a custom local search filter to the list of filters used to speed up local search by pruning unfeasible variable assignments. Calling this method after the routing model has been closed (CloseModel() or Solve() has been called) has no effect. The routing model does not take ownership of the filter.""" 4119 return _pywrapcp.RoutingModel_AddLocalSearchFilter(self, filter) 4120 4121 def Start(self, vehicle: "int") -> "int64_t": 4122 r""" Model inspection. Returns the variable index of the starting node of a vehicle route.""" 4123 return _pywrapcp.RoutingModel_Start(self, vehicle) 4124 4125 def End(self, vehicle: "int") -> "int64_t": 4126 r""" Returns the variable index of the ending node of a vehicle route.""" 4127 return _pywrapcp.RoutingModel_End(self, vehicle) 4128 4129 def IsStart(self, index: "int64_t") -> "bool": 4130 r""" Returns true if 'index' represents the first node of a route.""" 4131 return _pywrapcp.RoutingModel_IsStart(self, index) 4132 4133 def IsEnd(self, index: "int64_t") -> "bool": 4134 r""" Returns true if 'index' represents the last node of a route.""" 4135 return _pywrapcp.RoutingModel_IsEnd(self, index) 4136 4137 def VehicleIndex(self, index: "int64_t") -> "int": 4138 r""" Returns the vehicle of the given start/end index, and -1 if the given index is not a vehicle start/end.""" 4139 return _pywrapcp.RoutingModel_VehicleIndex(self, index) 4140 4141 def Next(self, assignment: "Assignment", index: "int64_t") -> "int64_t": 4142 r""" Assignment inspection Returns the variable index of the node directly after the node corresponding to 'index' in 'assignment'.""" 4143 return _pywrapcp.RoutingModel_Next(self, assignment, index) 4144 4145 def IsVehicleUsed(self, assignment: "Assignment", vehicle: "int") -> "bool": 4146 r""" Returns true if the route of 'vehicle' is non empty in 'assignment'.""" 4147 return _pywrapcp.RoutingModel_IsVehicleUsed(self, assignment, vehicle) 4148 4149 def NextVar(self, index: "int64_t") -> "operations_research::IntVar *": 4150 r""" Returns the next variable of the node corresponding to index. Note that NextVar(index) == index is equivalent to ActiveVar(index) == 0.""" 4151 return _pywrapcp.RoutingModel_NextVar(self, index) 4152 4153 def ActiveVar(self, index: "int64_t") -> "operations_research::IntVar *": 4154 r""" Returns the active variable of the node corresponding to index.""" 4155 return _pywrapcp.RoutingModel_ActiveVar(self, index) 4156 4157 def ActiveVehicleVar(self, vehicle: "int") -> "operations_research::IntVar *": 4158 r""" Returns the active variable of the vehicle. It will be equal to 1 iff the route of the vehicle is not empty, 0 otherwise.""" 4159 return _pywrapcp.RoutingModel_ActiveVehicleVar(self, vehicle) 4160 4161 def VehicleRouteConsideredVar(self, vehicle: "int") -> "operations_research::IntVar *": 4162 r""" Returns the variable specifying whether or not the given vehicle route is considered for costs and constraints. It will be equal to 1 iff the route of the vehicle is not empty OR vehicle_used_when_empty_[vehicle] is true.""" 4163 return _pywrapcp.RoutingModel_VehicleRouteConsideredVar(self, vehicle) 4164 4165 def VehicleVar(self, index: "int64_t") -> "operations_research::IntVar *": 4166 r""" Returns the vehicle variable of the node corresponding to index. Note that VehicleVar(index) == -1 is equivalent to ActiveVar(index) == 0.""" 4167 return _pywrapcp.RoutingModel_VehicleVar(self, index) 4168 4169 def ResourceVar(self, vehicle: "int", resource_group: "int") -> "operations_research::IntVar *": 4170 r""" Returns the resource variable for the given vehicle index in the given resource group. If a vehicle doesn't require a resource from the corresponding resource group, then ResourceVar(v, r_g) == -1.""" 4171 return _pywrapcp.RoutingModel_ResourceVar(self, vehicle, resource_group) 4172 4173 def CostVar(self) -> "operations_research::IntVar *": 4174 r""" Returns the global cost variable which is being minimized.""" 4175 return _pywrapcp.RoutingModel_CostVar(self) 4176 4177 def GetArcCostForVehicle(self, from_index: "int64_t", to_index: "int64_t", vehicle: "int64_t") -> "int64_t": 4178 r""" Returns the cost of the transit arc between two nodes for a given vehicle. Input are variable indices of node. This returns 0 if vehicle < 0.""" 4179 return _pywrapcp.RoutingModel_GetArcCostForVehicle(self, from_index, to_index, vehicle) 4180 4181 def CostsAreHomogeneousAcrossVehicles(self) -> "bool": 4182 r""" Whether costs are homogeneous across all vehicles.""" 4183 return _pywrapcp.RoutingModel_CostsAreHomogeneousAcrossVehicles(self) 4184 4185 def GetHomogeneousCost(self, from_index: "int64_t", to_index: "int64_t") -> "int64_t": 4186 r""" Returns the cost of the segment between two nodes supposing all vehicle costs are the same (returns the cost for the first vehicle otherwise).""" 4187 return _pywrapcp.RoutingModel_GetHomogeneousCost(self, from_index, to_index) 4188 4189 def GetArcCostForFirstSolution(self, from_index: "int64_t", to_index: "int64_t") -> "int64_t": 4190 r""" Returns the cost of the arc in the context of the first solution strategy. This is typically a simplification of the actual cost; see the .cc.""" 4191 return _pywrapcp.RoutingModel_GetArcCostForFirstSolution(self, from_index, to_index) 4192 4193 def GetArcCostForClass(self, from_index: "int64_t", to_index: "int64_t", cost_class_index: "int64_t") -> "int64_t": 4194 r""" Returns the cost of the segment between two nodes for a given cost class. Input are variable indices of nodes and the cost class. Unlike GetArcCostForVehicle(), if cost_class is kNoCost, then the returned cost won't necessarily be zero: only some of the components of the cost that depend on the cost class will be omited. See the code for details.""" 4195 return _pywrapcp.RoutingModel_GetArcCostForClass(self, from_index, to_index, cost_class_index) 4196 4197 def GetCostClassIndexOfVehicle(self, vehicle: "int64_t") -> "operations_research::RoutingModel::CostClassIndex": 4198 r""" Get the cost class index of the given vehicle.""" 4199 return _pywrapcp.RoutingModel_GetCostClassIndexOfVehicle(self, vehicle) 4200 4201 def HasVehicleWithCostClassIndex(self, cost_class_index: "operations_research::RoutingModel::CostClassIndex") -> "bool": 4202 r""" Returns true iff the model contains a vehicle with the given cost_class_index.""" 4203 return _pywrapcp.RoutingModel_HasVehicleWithCostClassIndex(self, cost_class_index) 4204 4205 def GetCostClassesCount(self) -> "int": 4206 r""" Returns the number of different cost classes in the model.""" 4207 return _pywrapcp.RoutingModel_GetCostClassesCount(self) 4208 4209 def GetNonZeroCostClassesCount(self) -> "int": 4210 r""" Ditto, minus the 'always zero', built-in cost class.""" 4211 return _pywrapcp.RoutingModel_GetNonZeroCostClassesCount(self) 4212 4213 def GetVehicleClassIndexOfVehicle(self, vehicle: "int64_t") -> "operations_research::RoutingModel::VehicleClassIndex": 4214 return _pywrapcp.RoutingModel_GetVehicleClassIndexOfVehicle(self, vehicle) 4215 4216 def GetVehicleOfClass(self, vehicle_class: "operations_research::RoutingModel::VehicleClassIndex") -> "int": 4217 r""" Returns a vehicle of the given vehicle class, and -1 if there are no vehicles for this class.""" 4218 return _pywrapcp.RoutingModel_GetVehicleOfClass(self, vehicle_class) 4219 4220 def GetVehicleClassesCount(self) -> "int": 4221 r""" Returns the number of different vehicle classes in the model.""" 4222 return _pywrapcp.RoutingModel_GetVehicleClassesCount(self) 4223 4224 def GetSameVehicleIndicesOfIndex(self, node: "int") -> "std::vector< int > const &": 4225 r""" Returns variable indices of nodes constrained to be on the same route.""" 4226 return _pywrapcp.RoutingModel_GetSameVehicleIndicesOfIndex(self, node) 4227 4228 def GetVehicleTypeContainer(self) -> "operations_research::RoutingModel::VehicleTypeContainer const &": 4229 return _pywrapcp.RoutingModel_GetVehicleTypeContainer(self) 4230 4231 def ArcIsMoreConstrainedThanArc(self, _from: "int64_t", to1: "int64_t", to2: "int64_t") -> "bool": 4232 r""" Returns whether the arc from->to1 is more constrained than from->to2, taking into account, in order: - whether the destination node isn't an end node - whether the destination node is mandatory - whether the destination node is bound to the same vehicle as the source - the "primary constrained" dimension (see SetPrimaryConstrainedDimension) It then breaks ties using, in order: - the arc cost (taking unperformed penalties into account) - the size of the vehicle vars of "to1" and "to2" (lowest size wins) - the value: the lowest value of the indices to1 and to2 wins. See the .cc for details. The more constrained arc is typically preferable when building a first solution. This method is intended to be used as a callback for the BestValueByComparisonSelector value selector. Args: from: the variable index of the source node to1: the variable index of the first candidate destination node. to2: the variable index of the second candidate destination node.""" 4233 return _pywrapcp.RoutingModel_ArcIsMoreConstrainedThanArc(self, _from, to1, to2) 4234 4235 def DebugOutputAssignment(self, solution_assignment: "Assignment", dimension_to_print: "std::string const &") -> "std::string": 4236 r""" Print some debugging information about an assignment, including the feasible intervals of the CumulVar for dimension "dimension_to_print" at each step of the routes. If "dimension_to_print" is omitted, all dimensions will be printed.""" 4237 return _pywrapcp.RoutingModel_DebugOutputAssignment(self, solution_assignment, dimension_to_print) 4238 4239 def solver(self) -> "operations_research::Solver *": 4240 r""" Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair containing the minimum and maximum of the CumulVar of the jth node on route i. - cumul_bounds[i][j].first is the minimum. - cumul_bounds[i][j].second is the maximum. Returns the underlying constraint solver. Can be used to add extra constraints and/or modify search algorithms.""" 4241 return _pywrapcp.RoutingModel_solver(self) 4242 4243 def CheckLimit(self) -> "bool": 4244 r""" Returns true if the search limit has been crossed.""" 4245 return _pywrapcp.RoutingModel_CheckLimit(self) 4246 4247 def RemainingTime(self) -> "absl::Duration": 4248 r""" Returns the time left in the search limit.""" 4249 return _pywrapcp.RoutingModel_RemainingTime(self) 4250 4251 def nodes(self) -> "int": 4252 r""" Sizes and indices Returns the number of nodes in the model.""" 4253 return _pywrapcp.RoutingModel_nodes(self) 4254 4255 def vehicles(self) -> "int": 4256 r""" Returns the number of vehicle routes in the model.""" 4257 return _pywrapcp.RoutingModel_vehicles(self) 4258 4259 def Size(self) -> "int64_t": 4260 r""" Returns the number of next variables in the model.""" 4261 return _pywrapcp.RoutingModel_Size(self) 4262 4263 def GetNumberOfDecisionsInFirstSolution(self, search_parameters: "operations_research::RoutingSearchParameters const &") -> "int64_t": 4264 r""" Returns statistics on first solution search, number of decisions sent to filters, number of decisions rejected by filters.""" 4265 return _pywrapcp.RoutingModel_GetNumberOfDecisionsInFirstSolution(self, search_parameters) 4266 4267 def GetNumberOfRejectsInFirstSolution(self, search_parameters: "operations_research::RoutingSearchParameters const &") -> "int64_t": 4268 return _pywrapcp.RoutingModel_GetNumberOfRejectsInFirstSolution(self, search_parameters) 4269 4270 def GetAutomaticFirstSolutionStrategy(self) -> "operations_research::FirstSolutionStrategy::Value": 4271 r""" Returns the automatic first solution strategy selected.""" 4272 return _pywrapcp.RoutingModel_GetAutomaticFirstSolutionStrategy(self) 4273 4274 def IsMatchingModel(self) -> "bool": 4275 r""" Returns true if a vehicle/node matching problem is detected.""" 4276 return _pywrapcp.RoutingModel_IsMatchingModel(self) 4277 4278 def AreRoutesInterdependent(self, parameters: "operations_research::RoutingSearchParameters const &") -> "bool": 4279 r""" Returns true if routes are interdependent. This means that any modification to a route might impact another.""" 4280 return _pywrapcp.RoutingModel_AreRoutesInterdependent(self, parameters) 4281 4282 def MakeGuidedSlackFinalizer(self, dimension: "RoutingDimension", initializer: "std::function< int64_t (int64_t) >") -> "operations_research::DecisionBuilder *": 4283 r""" The next few members are in the public section only for testing purposes. MakeGuidedSlackFinalizer creates a DecisionBuilder for the slacks of a dimension using a callback to choose which values to start with. The finalizer works only when all next variables in the model have been fixed. It has the following two characteristics: 1. It follows the routes defined by the nexts variables when choosing a variable to make a decision on. 2. When it comes to choose a value for the slack of node i, the decision builder first calls the callback with argument i, and supposingly the returned value is x it creates decisions slack[i] = x, slack[i] = x + 1, slack[i] = x - 1, slack[i] = x + 2, etc.""" 4284 return _pywrapcp.RoutingModel_MakeGuidedSlackFinalizer(self, dimension, initializer) 4285 4286 def MakeSelfDependentDimensionFinalizer(self, dimension: "RoutingDimension") -> "operations_research::DecisionBuilder *": 4287 r""" MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a self-dependent dimension. It makes an extensive use of the caches of the state dependent transits. In detail, MakeSelfDependentDimensionFinalizer returns a composition of a local search decision builder with a greedy descent operator for the cumul of the start of each route and a guided slack finalizer. Provided there are no time windows and the maximum slacks are large enough, once the cumul of the start of route is fixed, the guided finalizer can find optimal values of the slacks for the rest of the route in time proportional to the length of the route. Therefore the composed finalizer generally works in time O(log(t)*n*m), where t is the latest possible departute time, n is the number of nodes in the network and m is the number of vehicles.""" 4288 return _pywrapcp.RoutingModel_MakeSelfDependentDimensionFinalizer(self, dimension) 4289 4290# Register RoutingModel in _pywrapcp: 4291_pywrapcp.RoutingModel_swigregister(RoutingModel) 4292cvar = _pywrapcp.cvar 4293RoutingModel.kNoPenalty = _pywrapcp.cvar.RoutingModel_kNoPenalty 4294RoutingModel.kNoDisjunction = _pywrapcp.cvar.RoutingModel_kNoDisjunction 4295RoutingModel.kNoDimension = _pywrapcp.cvar.RoutingModel_kNoDimension 4296 4297class RoutingModelVisitor(BaseObject): 4298 r""" Routing model visitor.""" 4299 4300 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 4301 __repr__ = _swig_repr 4302 4303 def __init__(self): 4304 _pywrapcp.RoutingModelVisitor_swiginit(self, _pywrapcp.new_RoutingModelVisitor()) 4305 __swig_destroy__ = _pywrapcp.delete_RoutingModelVisitor 4306 4307# Register RoutingModelVisitor in _pywrapcp: 4308_pywrapcp.RoutingModelVisitor_swigregister(RoutingModelVisitor) 4309RoutingModelVisitor.kLightElement = _pywrapcp.cvar.RoutingModelVisitor_kLightElement 4310RoutingModelVisitor.kLightElement2 = _pywrapcp.cvar.RoutingModelVisitor_kLightElement2 4311RoutingModelVisitor.kRemoveValues = _pywrapcp.cvar.RoutingModelVisitor_kRemoveValues 4312 4313class GlobalVehicleBreaksConstraint(Constraint): 4314 r""" GlobalVehicleBreaksConstraint ensures breaks constraints are enforced on all vehicles in the dimension passed to its constructor. It is intended to be used for dimensions representing time. A break constraint ensures break intervals fit on the route of a vehicle. For a given vehicle, it forces break intervals to be disjoint from visit intervals, where visit intervals start at CumulVar(node) and last for node_visit_transit[node]. Moreover, it ensures that there is enough time between two consecutive nodes of a route to do transit and vehicle breaks, i.e. if Next(nodeA) = nodeB, CumulVar(nodeA) = tA and CumulVar(nodeB) = tB, then SlackVar(nodeA) >= sum_{breaks [tA, tB)} duration(break).""" 4315 4316 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 4317 __repr__ = _swig_repr 4318 4319 def __init__(self, dimension: "RoutingDimension"): 4320 _pywrapcp.GlobalVehicleBreaksConstraint_swiginit(self, _pywrapcp.new_GlobalVehicleBreaksConstraint(dimension)) 4321 4322 def DebugString(self) -> "std::string": 4323 return _pywrapcp.GlobalVehicleBreaksConstraint_DebugString(self) 4324 4325 def Post(self) -> "void": 4326 return _pywrapcp.GlobalVehicleBreaksConstraint_Post(self) 4327 4328 def InitialPropagateWrapper(self) -> "void": 4329 return _pywrapcp.GlobalVehicleBreaksConstraint_InitialPropagateWrapper(self) 4330 __swig_destroy__ = _pywrapcp.delete_GlobalVehicleBreaksConstraint 4331 4332# Register GlobalVehicleBreaksConstraint in _pywrapcp: 4333_pywrapcp.GlobalVehicleBreaksConstraint_swigregister(GlobalVehicleBreaksConstraint) 4334 4335class TypeRegulationsChecker(object): 4336 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 4337 4338 def __init__(self, *args, **kwargs): 4339 raise AttributeError("No constructor defined - class is abstract") 4340 __repr__ = _swig_repr 4341 __swig_destroy__ = _pywrapcp.delete_TypeRegulationsChecker 4342 4343 def CheckVehicle(self, vehicle: "int", next_accessor: "std::function< int64_t (int64_t) > const &") -> "bool": 4344 return _pywrapcp.TypeRegulationsChecker_CheckVehicle(self, vehicle, next_accessor) 4345 4346# Register TypeRegulationsChecker in _pywrapcp: 4347_pywrapcp.TypeRegulationsChecker_swigregister(TypeRegulationsChecker) 4348 4349class TypeIncompatibilityChecker(TypeRegulationsChecker): 4350 r""" Checker for type incompatibilities.""" 4351 4352 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 4353 __repr__ = _swig_repr 4354 4355 def __init__(self, model: "RoutingModel", check_hard_incompatibilities: "bool"): 4356 _pywrapcp.TypeIncompatibilityChecker_swiginit(self, _pywrapcp.new_TypeIncompatibilityChecker(model, check_hard_incompatibilities)) 4357 __swig_destroy__ = _pywrapcp.delete_TypeIncompatibilityChecker 4358 4359# Register TypeIncompatibilityChecker in _pywrapcp: 4360_pywrapcp.TypeIncompatibilityChecker_swigregister(TypeIncompatibilityChecker) 4361 4362class TypeRequirementChecker(TypeRegulationsChecker): 4363 r""" Checker for type requirements.""" 4364 4365 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 4366 __repr__ = _swig_repr 4367 4368 def __init__(self, model: "RoutingModel"): 4369 _pywrapcp.TypeRequirementChecker_swiginit(self, _pywrapcp.new_TypeRequirementChecker(model)) 4370 __swig_destroy__ = _pywrapcp.delete_TypeRequirementChecker 4371 4372# Register TypeRequirementChecker in _pywrapcp: 4373_pywrapcp.TypeRequirementChecker_swigregister(TypeRequirementChecker) 4374 4375class TypeRegulationsConstraint(Constraint): 4376 r""" The following constraint ensures that incompatibilities and requirements between types are respected. It verifies both "hard" and "temporal" incompatibilities. Two nodes with hard incompatible types cannot be served by the same vehicle at all, while with a temporal incompatibility they can't be on the same route at the same time. The VisitTypePolicy of a node determines how visiting it impacts the type count on the route. For example, for - three temporally incompatible types T1 T2 and T3 - 2 pairs of nodes a1/r1 and a2/r2 of type T1 and T2 respectively, with - a1 and a2 of VisitTypePolicy TYPE_ADDED_TO_VEHICLE - r1 and r2 of policy ADDED_TYPE_REMOVED_FROM_VEHICLE - 3 nodes A, UV and AR of type T3, respectively with type policies TYPE_ADDED_TO_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT and TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED the configurations UV --> a1 --> r1 --> a2 --> r2, a1 --> r1 --> a2 --> r2 --> A and a1 --> r1 --> AR --> a2 --> r2 are acceptable, whereas the configurations a1 --> a2 --> r1 --> ..., or A --> a1 --> r1 --> ..., or a1 --> r1 --> UV --> ... are not feasible. It also verifies same-vehicle and temporal type requirements. A node of type T_d with a same-vehicle requirement for type T_r needs to be served by the same vehicle as a node of type T_r. Temporal requirements, on the other hand, can take effect either when the dependent type is being added to the route or when it's removed from it, which is determined by the dependent node's VisitTypePolicy. In the above example: - If T3 is required on the same vehicle as T1, A, AR or UV must be on the same vehicle as a1. - If T2 is required when adding T1, a2 must be visited *before* a1, and if r2 is also visited on the route, it must be *after* a1, i.e. T2 must be on the vehicle when a1 is visited: ... --> a2 --> ... --> a1 --> ... --> r2 --> ... - If T3 is required when removing T1, T3 needs to be on the vehicle when r1 is visited: ... --> A --> ... --> r1 --> ... OR ... --> r1 --> ... --> UV --> ...""" 4377 4378 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 4379 __repr__ = _swig_repr 4380 4381 def __init__(self, model: "RoutingModel"): 4382 _pywrapcp.TypeRegulationsConstraint_swiginit(self, _pywrapcp.new_TypeRegulationsConstraint(model)) 4383 4384 def Post(self) -> "void": 4385 return _pywrapcp.TypeRegulationsConstraint_Post(self) 4386 4387 def InitialPropagateWrapper(self) -> "void": 4388 return _pywrapcp.TypeRegulationsConstraint_InitialPropagateWrapper(self) 4389 __swig_destroy__ = _pywrapcp.delete_TypeRegulationsConstraint 4390 4391# Register TypeRegulationsConstraint in _pywrapcp: 4392_pywrapcp.TypeRegulationsConstraint_swigregister(TypeRegulationsConstraint) 4393 4394class RoutingDimension(object): 4395 r""" Dimensions represent quantities accumulated at nodes along the routes. They represent quantities such as weights or volumes carried along the route, or distance or times. Quantities at a node are represented by "cumul" variables and the increase or decrease of quantities between nodes are represented by "transit" variables. These variables are linked as follows: if j == next(i), cumuls(j) = cumuls(i) + transits(i) + slacks(i) + state_dependent_transits(i) where slack is a positive slack variable (can represent waiting times for a time dimension), and state_dependent_transits is a non-purely functional version of transits_. Favour transits over state_dependent_transits when possible, because purely functional callbacks allow more optimisations and make the model faster and easier to solve. for a given vehicle, it is passed as an external vector, it would be better to have this information here.""" 4396 4397 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 4398 4399 def __init__(self, *args, **kwargs): 4400 raise AttributeError("No constructor defined") 4401 __repr__ = _swig_repr 4402 __swig_destroy__ = _pywrapcp.delete_RoutingDimension 4403 4404 def model(self) -> "operations_research::RoutingModel *": 4405 r""" Returns the model on which the dimension was created.""" 4406 return _pywrapcp.RoutingDimension_model(self) 4407 4408 def GetTransitValue(self, from_index: "int64_t", to_index: "int64_t", vehicle: "int64_t") -> "int64_t": 4409 r""" Returns the transition value for a given pair of nodes (as var index); this value is the one taken by the corresponding transit variable when the 'next' variable for 'from_index' is bound to 'to_index'.""" 4410 return _pywrapcp.RoutingDimension_GetTransitValue(self, from_index, to_index, vehicle) 4411 4412 def GetTransitValueFromClass(self, from_index: "int64_t", to_index: "int64_t", vehicle_class: "int64_t") -> "int64_t": 4413 r""" Same as above but taking a vehicle class of the dimension instead of a vehicle (the class of a vehicle can be obtained with vehicle_to_class()).""" 4414 return _pywrapcp.RoutingDimension_GetTransitValueFromClass(self, from_index, to_index, vehicle_class) 4415 4416 def CumulVar(self, index: "int64_t") -> "operations_research::IntVar *": 4417 r""" Get the cumul, transit and slack variables for the given node (given as int64_t var index).""" 4418 return _pywrapcp.RoutingDimension_CumulVar(self, index) 4419 4420 def TransitVar(self, index: "int64_t") -> "operations_research::IntVar *": 4421 return _pywrapcp.RoutingDimension_TransitVar(self, index) 4422 4423 def FixedTransitVar(self, index: "int64_t") -> "operations_research::IntVar *": 4424 return _pywrapcp.RoutingDimension_FixedTransitVar(self, index) 4425 4426 def SlackVar(self, index: "int64_t") -> "operations_research::IntVar *": 4427 return _pywrapcp.RoutingDimension_SlackVar(self, index) 4428 4429 def SetSpanUpperBoundForVehicle(self, upper_bound: "int64_t", vehicle: "int") -> "void": 4430 r""" Sets an upper bound on the dimension span on a given vehicle. This is the preferred way to limit the "length" of the route of a vehicle according to a dimension.""" 4431 return _pywrapcp.RoutingDimension_SetSpanUpperBoundForVehicle(self, upper_bound, vehicle) 4432 4433 def SetSpanCostCoefficientForVehicle(self, coefficient: "int64_t", vehicle: "int") -> "void": 4434 r""" Sets a cost proportional to the dimension span on a given vehicle, or on all vehicles at once. "coefficient" must be nonnegative. This is handy to model costs proportional to idle time when the dimension represents time. The cost for a vehicle is span_cost = coefficient * (dimension end value - dimension start value).""" 4435 return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForVehicle(self, coefficient, vehicle) 4436 4437 def SetSpanCostCoefficientForAllVehicles(self, coefficient: "int64_t") -> "void": 4438 return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForAllVehicles(self, coefficient) 4439 4440 def SetGlobalSpanCostCoefficient(self, coefficient: "int64_t") -> "void": 4441 r""" Sets a cost proportional to the *global* dimension span, that is the difference between the largest value of route end cumul variables and the smallest value of route start cumul variables. In other words: global_span_cost = coefficient * (Max(dimension end value) - Min(dimension start value)).""" 4442 return _pywrapcp.RoutingDimension_SetGlobalSpanCostCoefficient(self, coefficient) 4443 4444 def SetCumulVarSoftUpperBound(self, index: "int64_t", upper_bound: "int64_t", coefficient: "int64_t") -> "void": 4445 r""" Sets a soft upper bound to the cumul variable of a given variable index. If the value of the cumul variable is greater than the bound, a cost proportional to the difference between this value and the bound is added to the cost function of the model: cumulVar <= upper_bound -> cost = 0 cumulVar > upper_bound -> cost = coefficient * (cumulVar - upper_bound) This is also handy to model tardiness costs when the dimension represents time.""" 4446 return _pywrapcp.RoutingDimension_SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient) 4447 4448 def HasCumulVarSoftUpperBound(self, index: "int64_t") -> "bool": 4449 r""" Returns true if a soft upper bound has been set for a given variable index.""" 4450 return _pywrapcp.RoutingDimension_HasCumulVarSoftUpperBound(self, index) 4451 4452 def GetCumulVarSoftUpperBound(self, index: "int64_t") -> "int64_t": 4453 r""" Returns the soft upper bound of a cumul variable for a given variable index. The "hard" upper bound of the variable is returned if no soft upper bound has been set.""" 4454 return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBound(self, index) 4455 4456 def GetCumulVarSoftUpperBoundCoefficient(self, index: "int64_t") -> "int64_t": 4457 r""" Returns the cost coefficient of the soft upper bound of a cumul variable for a given variable index. If no soft upper bound has been set, 0 is returned.""" 4458 return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBoundCoefficient(self, index) 4459 4460 def SetCumulVarSoftLowerBound(self, index: "int64_t", lower_bound: "int64_t", coefficient: "int64_t") -> "void": 4461 r""" Sets a soft lower bound to the cumul variable of a given variable index. If the value of the cumul variable is less than the bound, a cost proportional to the difference between this value and the bound is added to the cost function of the model: cumulVar > lower_bound -> cost = 0 cumulVar <= lower_bound -> cost = coefficient * (lower_bound - cumulVar). This is also handy to model earliness costs when the dimension represents time.""" 4462 return _pywrapcp.RoutingDimension_SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient) 4463 4464 def HasCumulVarSoftLowerBound(self, index: "int64_t") -> "bool": 4465 r""" Returns true if a soft lower bound has been set for a given variable index.""" 4466 return _pywrapcp.RoutingDimension_HasCumulVarSoftLowerBound(self, index) 4467 4468 def GetCumulVarSoftLowerBound(self, index: "int64_t") -> "int64_t": 4469 r""" Returns the soft lower bound of a cumul variable for a given variable index. The "hard" lower bound of the variable is returned if no soft lower bound has been set.""" 4470 return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBound(self, index) 4471 4472 def GetCumulVarSoftLowerBoundCoefficient(self, index: "int64_t") -> "int64_t": 4473 r""" Returns the cost coefficient of the soft lower bound of a cumul variable for a given variable index. If no soft lower bound has been set, 0 is returned.""" 4474 return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBoundCoefficient(self, index) 4475 4476 def SetBreakIntervalsOfVehicle(self, breaks: "std::vector< operations_research::IntervalVar * >", vehicle: "int", node_visit_transits: "std::vector< int64_t >") -> "void": 4477 r""" Sets the breaks for a given vehicle. Breaks are represented by IntervalVars. They may interrupt transits between nodes and increase the value of corresponding slack variables. A break may take place before the start of a vehicle, after the end of a vehicle, or during a travel i -> j. In that case, the interval [break.Start(), break.End()) must be a subset of [CumulVar(i) + pre_travel(i, j), CumulVar(j) - post_travel(i, j)). In other words, a break may not overlap any node n's visit, given by [CumulVar(n) - post_travel(_, n), CumulVar(n) + pre_travel(n, _)). This formula considers post_travel(_, start) and pre_travel(end, _) to be 0; pre_travel will never be called on any (_, start) and post_travel will never we called on any (end, _). If pre_travel_evaluator or post_travel_evaluator is -1, it will be taken as a function that always returns 0. Deprecated, sets pre_travel(i, j) = node_visit_transit[i].""" 4478 return _pywrapcp.RoutingDimension_SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits) 4479 4480 def SetBreakDistanceDurationOfVehicle(self, distance: "int64_t", duration: "int64_t", vehicle: "int") -> "void": 4481 r""" With breaks supposed to be consecutive, this forces the distance between breaks of size at least minimum_break_duration to be at most distance. This supposes that the time until route start and after route end are infinite breaks.""" 4482 return _pywrapcp.RoutingDimension_SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle) 4483 4484 def InitializeBreaks(self) -> "void": 4485 r""" Sets up vehicle_break_intervals_, vehicle_break_distance_duration_, pre_travel_evaluators and post_travel_evaluators.""" 4486 return _pywrapcp.RoutingDimension_InitializeBreaks(self) 4487 4488 def HasBreakConstraints(self) -> "bool": 4489 r""" Returns true if any break interval or break distance was defined.""" 4490 return _pywrapcp.RoutingDimension_HasBreakConstraints(self) 4491 4492 def GetBreakIntervalsOfVehicle(self, vehicle: "int") -> "std::vector< operations_research::IntervalVar * > const &": 4493 r""" Returns the break intervals set by SetBreakIntervalsOfVehicle().""" 4494 return _pywrapcp.RoutingDimension_GetBreakIntervalsOfVehicle(self, vehicle) 4495 4496 def GetBreakDistanceDurationOfVehicle(self, vehicle: "int") -> "std::vector< std::pair< int64_t,int64_t > > const &": 4497 r""" Returns the pairs (distance, duration) specified by break distance constraints.""" 4498 return _pywrapcp.RoutingDimension_GetBreakDistanceDurationOfVehicle(self, vehicle) 4499 4500 def GetPreTravelEvaluatorOfVehicle(self, vehicle: "int") -> "int": 4501 return _pywrapcp.RoutingDimension_GetPreTravelEvaluatorOfVehicle(self, vehicle) 4502 4503 def GetPostTravelEvaluatorOfVehicle(self, vehicle: "int") -> "int": 4504 return _pywrapcp.RoutingDimension_GetPostTravelEvaluatorOfVehicle(self, vehicle) 4505 4506 def base_dimension(self) -> "operations_research::RoutingDimension const *": 4507 r""" Returns the parent in the dependency tree if any or nullptr otherwise.""" 4508 return _pywrapcp.RoutingDimension_base_dimension(self) 4509 4510 def ShortestTransitionSlack(self, node: "int64_t") -> "int64_t": 4511 r""" It makes sense to use the function only for self-dependent dimension. For such dimensions the value of the slack of a node determines the transition cost of the next transit. Provided that 1. cumul[node] is fixed, 2. next[node] and next[next[node]] (if exists) are fixed, the value of slack[node] for which cumul[next[node]] + transit[next[node]] is minimized can be found in O(1) using this function.""" 4512 return _pywrapcp.RoutingDimension_ShortestTransitionSlack(self, node) 4513 4514 def name(self) -> "std::string const &": 4515 r""" Returns the name of the dimension.""" 4516 return _pywrapcp.RoutingDimension_name(self) 4517 4518 def SetPickupToDeliveryLimitFunctionForPair(self, limit_function: "operations_research::RoutingDimension::PickupToDeliveryLimitFunction", pair_index: "int") -> "void": 4519 return _pywrapcp.RoutingDimension_SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index) 4520 4521 def HasPickupToDeliveryLimits(self) -> "bool": 4522 return _pywrapcp.RoutingDimension_HasPickupToDeliveryLimits(self) 4523 4524 def AddNodePrecedence(self, first_node: "int64_t", second_node: "int64_t", offset: "int64_t") -> "void": 4525 return _pywrapcp.RoutingDimension_AddNodePrecedence(self, first_node, second_node, offset) 4526 4527 def GetSpanUpperBoundForVehicle(self, vehicle: "int") -> "int64_t": 4528 return _pywrapcp.RoutingDimension_GetSpanUpperBoundForVehicle(self, vehicle) 4529 4530 def GetSpanCostCoefficientForVehicle(self, vehicle: "int") -> "int64_t": 4531 return _pywrapcp.RoutingDimension_GetSpanCostCoefficientForVehicle(self, vehicle) 4532 4533 def global_span_cost_coefficient(self) -> "int64_t": 4534 return _pywrapcp.RoutingDimension_global_span_cost_coefficient(self) 4535 4536 def GetGlobalOptimizerOffset(self) -> "int64_t": 4537 return _pywrapcp.RoutingDimension_GetGlobalOptimizerOffset(self) 4538 4539 def GetLocalOptimizerOffsetForVehicle(self, vehicle: "int") -> "int64_t": 4540 return _pywrapcp.RoutingDimension_GetLocalOptimizerOffsetForVehicle(self, vehicle) 4541 4542# Register RoutingDimension in _pywrapcp: 4543_pywrapcp.RoutingDimension_swigregister(RoutingDimension) 4544 4545 4546def MakeSetValuesFromTargets(solver: "Solver", variables: "std::vector< operations_research::IntVar * >", targets: "std::vector< int64_t >") -> "operations_research::DecisionBuilder *": 4547 r""" A decision builder which tries to assign values to variables as close as possible to target values first.""" 4548 return _pywrapcp.MakeSetValuesFromTargets(solver, variables, targets) 4549 4550def SolveModelWithSat(model: "RoutingModel", search_parameters: "operations_research::RoutingSearchParameters const &", initial_solution: "Assignment", solution: "Assignment") -> "bool": 4551 r""" Attempts to solve the model using the cp-sat solver. As of 5/2019, will solve the TSP corresponding to the model if it has a single vehicle. Therefore the resulting solution might not actually be feasible. Will return false if a solution could not be found.""" 4552 return _pywrapcp.SolveModelWithSat(model, search_parameters, initial_solution, solution)
67class DefaultPhaseParameters(object): 68 r""" This struct holds all parameters for the default search. DefaultPhaseParameters is only used by Solver::MakeDefaultPhase methods. Note this is for advanced users only.""" 69 70 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 71 __repr__ = _swig_repr 72 CHOOSE_MAX_SUM_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_SUM_IMPACT 73 CHOOSE_MAX_AVERAGE_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_AVERAGE_IMPACT 74 CHOOSE_MAX_VALUE_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_VALUE_IMPACT 75 SELECT_MIN_IMPACT = _pywrapcp.DefaultPhaseParameters_SELECT_MIN_IMPACT 76 SELECT_MAX_IMPACT = _pywrapcp.DefaultPhaseParameters_SELECT_MAX_IMPACT 77 NONE = _pywrapcp.DefaultPhaseParameters_NONE 78 NORMAL = _pywrapcp.DefaultPhaseParameters_NORMAL 79 VERBOSE = _pywrapcp.DefaultPhaseParameters_VERBOSE 80 var_selection_schema = property(_pywrapcp.DefaultPhaseParameters_var_selection_schema_get, _pywrapcp.DefaultPhaseParameters_var_selection_schema_set, doc=r""" This parameter describes how the next variable to instantiate will be chosen.""") 81 value_selection_schema = property(_pywrapcp.DefaultPhaseParameters_value_selection_schema_get, _pywrapcp.DefaultPhaseParameters_value_selection_schema_set, doc=r""" This parameter describes which value to select for a given var.""") 82 initialization_splits = property(_pywrapcp.DefaultPhaseParameters_initialization_splits_get, _pywrapcp.DefaultPhaseParameters_initialization_splits_set, doc=r""" Maximum number of intervals that the initialization of impacts will scan per variable.""") 83 run_all_heuristics = property(_pywrapcp.DefaultPhaseParameters_run_all_heuristics_get, _pywrapcp.DefaultPhaseParameters_run_all_heuristics_set, doc=r""" The default phase will run heuristics periodically. This parameter indicates if we should run all heuristics, or a randomly selected one.""") 84 heuristic_period = property(_pywrapcp.DefaultPhaseParameters_heuristic_period_get, _pywrapcp.DefaultPhaseParameters_heuristic_period_set, doc=r""" The distance in nodes between each run of the heuristics. A negative or null value will mean that we will not run heuristics at all.""") 85 heuristic_num_failures_limit = property(_pywrapcp.DefaultPhaseParameters_heuristic_num_failures_limit_get, _pywrapcp.DefaultPhaseParameters_heuristic_num_failures_limit_set, doc=r""" The failure limit for each heuristic that we run.""") 86 persistent_impact = property(_pywrapcp.DefaultPhaseParameters_persistent_impact_get, _pywrapcp.DefaultPhaseParameters_persistent_impact_set, doc=r""" Whether to keep the impact from the first search for other searches, or to recompute the impact for each new search.""") 87 random_seed = property(_pywrapcp.DefaultPhaseParameters_random_seed_get, _pywrapcp.DefaultPhaseParameters_random_seed_set, doc=r""" Seed used to initialize the random part in some heuristics.""") 88 display_level = property(_pywrapcp.DefaultPhaseParameters_display_level_get, _pywrapcp.DefaultPhaseParameters_display_level_set, doc=r""" This represents the amount of information displayed by the default search. NONE means no display, VERBOSE means extra information.""") 89 decision_builder = property(_pywrapcp.DefaultPhaseParameters_decision_builder_get, _pywrapcp.DefaultPhaseParameters_decision_builder_set, doc=r""" When defined, this overrides the default impact based decision builder.""") 90 91 def __init__(self): 92 _pywrapcp.DefaultPhaseParameters_swiginit(self, _pywrapcp.new_DefaultPhaseParameters()) 93 __swig_destroy__ = _pywrapcp.delete_DefaultPhaseParameters
This struct holds all parameters for the default search. DefaultPhaseParameters is only used by Solver::MakeDefaultPhase methods. Note this is for advanced users only.
Maximum number of intervals that the initialization of impacts will scan per variable.
The default phase will run heuristics periodically. This parameter indicates if we should run all heuristics, or a randomly selected one.
The distance in nodes between each run of the heuristics. A negative or null value will mean that we will not run heuristics at all.
Whether to keep the impact from the first search for other searches, or to recompute the impact for each new search.
98class Solver(object): 99 r""" Solver Class A solver represents the main computation engine. It implements the entire range of Constraint Programming protocols: - Reversibility - Propagation - Search Usually, Constraint Programming code consists of - the creation of the Solver, - the creation of the decision variables of the model, - the creation of the constraints of the model and their addition to the solver() through the AddConstraint() method, - the creation of the main DecisionBuilder class, - the launch of the solve() method with the decision builder. For the time being, Solver is neither MT_SAFE nor MT_HOT.""" 100 101 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 102 __repr__ = _swig_repr 103 INT_VAR_DEFAULT = _pywrapcp.Solver_INT_VAR_DEFAULT 104 r""" The default behavior is CHOOSE_FIRST_UNBOUND.""" 105 INT_VAR_SIMPLE = _pywrapcp.Solver_INT_VAR_SIMPLE 106 r""" The simple selection is CHOOSE_FIRST_UNBOUND.""" 107 CHOOSE_FIRST_UNBOUND = _pywrapcp.Solver_CHOOSE_FIRST_UNBOUND 108 r""" Select the first unbound variable. Variables are considered in the order of the vector of IntVars used to create the selector.""" 109 CHOOSE_RANDOM = _pywrapcp.Solver_CHOOSE_RANDOM 110 r""" Randomly select one of the remaining unbound variables.""" 111 CHOOSE_MIN_SIZE_LOWEST_MIN = _pywrapcp.Solver_CHOOSE_MIN_SIZE_LOWEST_MIN 112 r""" Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variables is the one with the lowest min value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.""" 113 CHOOSE_MIN_SIZE_HIGHEST_MIN = _pywrapcp.Solver_CHOOSE_MIN_SIZE_HIGHEST_MIN 114 r""" Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variable is the one with the highest min value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.""" 115 CHOOSE_MIN_SIZE_LOWEST_MAX = _pywrapcp.Solver_CHOOSE_MIN_SIZE_LOWEST_MAX 116 r""" Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variables is the one with the lowest max value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.""" 117 CHOOSE_MIN_SIZE_HIGHEST_MAX = _pywrapcp.Solver_CHOOSE_MIN_SIZE_HIGHEST_MAX 118 r""" Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variable is the one with the highest max value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.""" 119 CHOOSE_LOWEST_MIN = _pywrapcp.Solver_CHOOSE_LOWEST_MIN 120 r""" Among unbound variables, select the variable with the smallest minimal value. In case of a tie, the first one is selected, "first" defined by the order in the vector of IntVars used to create the selector.""" 121 CHOOSE_HIGHEST_MAX = _pywrapcp.Solver_CHOOSE_HIGHEST_MAX 122 r""" Among unbound variables, select the variable with the highest maximal value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.""" 123 CHOOSE_MIN_SIZE = _pywrapcp.Solver_CHOOSE_MIN_SIZE 124 r""" Among unbound variables, select the variable with the smallest size. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.""" 125 CHOOSE_MAX_SIZE = _pywrapcp.Solver_CHOOSE_MAX_SIZE 126 r""" Among unbound variables, select the variable with the highest size. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.""" 127 CHOOSE_MAX_REGRET_ON_MIN = _pywrapcp.Solver_CHOOSE_MAX_REGRET_ON_MIN 128 r""" Among unbound variables, select the variable with the largest gap between the first and the second values of the domain.""" 129 CHOOSE_PATH = _pywrapcp.Solver_CHOOSE_PATH 130 r""" Selects the next unbound variable on a path, the path being defined by the variables: var[i] corresponds to the index of the next of i.""" 131 INT_VALUE_DEFAULT = _pywrapcp.Solver_INT_VALUE_DEFAULT 132 r""" The default behavior is ASSIGN_MIN_VALUE.""" 133 INT_VALUE_SIMPLE = _pywrapcp.Solver_INT_VALUE_SIMPLE 134 r""" The simple selection is ASSIGN_MIN_VALUE.""" 135 ASSIGN_MIN_VALUE = _pywrapcp.Solver_ASSIGN_MIN_VALUE 136 r""" Selects the min value of the selected variable.""" 137 ASSIGN_MAX_VALUE = _pywrapcp.Solver_ASSIGN_MAX_VALUE 138 r""" Selects the max value of the selected variable.""" 139 ASSIGN_RANDOM_VALUE = _pywrapcp.Solver_ASSIGN_RANDOM_VALUE 140 r""" Selects randomly one of the possible values of the selected variable.""" 141 ASSIGN_CENTER_VALUE = _pywrapcp.Solver_ASSIGN_CENTER_VALUE 142 r""" Selects the first possible value which is the closest to the center of the domain of the selected variable. The center is defined as (min + max) / 2.""" 143 SPLIT_LOWER_HALF = _pywrapcp.Solver_SPLIT_LOWER_HALF 144 r""" Split the domain in two around the center, and choose the lower part first.""" 145 SPLIT_UPPER_HALF = _pywrapcp.Solver_SPLIT_UPPER_HALF 146 r""" Split the domain in two around the center, and choose the lower part first.""" 147 SEQUENCE_DEFAULT = _pywrapcp.Solver_SEQUENCE_DEFAULT 148 SEQUENCE_SIMPLE = _pywrapcp.Solver_SEQUENCE_SIMPLE 149 CHOOSE_MIN_SLACK_RANK_FORWARD = _pywrapcp.Solver_CHOOSE_MIN_SLACK_RANK_FORWARD 150 CHOOSE_RANDOM_RANK_FORWARD = _pywrapcp.Solver_CHOOSE_RANDOM_RANK_FORWARD 151 INTERVAL_DEFAULT = _pywrapcp.Solver_INTERVAL_DEFAULT 152 r""" The default is INTERVAL_SET_TIMES_FORWARD.""" 153 INTERVAL_SIMPLE = _pywrapcp.Solver_INTERVAL_SIMPLE 154 r""" The simple is INTERVAL_SET_TIMES_FORWARD.""" 155 INTERVAL_SET_TIMES_FORWARD = _pywrapcp.Solver_INTERVAL_SET_TIMES_FORWARD 156 r""" Selects the variable with the lowest starting time of all variables, and fixes its starting time to this lowest value.""" 157 INTERVAL_SET_TIMES_BACKWARD = _pywrapcp.Solver_INTERVAL_SET_TIMES_BACKWARD 158 r""" Selects the variable with the highest ending time of all variables, and fixes the ending time to this highest values.""" 159 TWOOPT = _pywrapcp.Solver_TWOOPT 160 r""" Operator which reverses a sub-chain of a path. It is called TwoOpt because it breaks two arcs on the path; resulting paths are called two-optimal. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> [3 -> 2] -> 4 -> 5 1 -> [4 -> 3 -> 2] -> 5 1 -> 2 -> [4 -> 3] -> 5""" 161 OROPT = _pywrapcp.Solver_OROPT 162 r""" Relocate: OROPT and RELOCATE. Operator which moves a sub-chain of a path to another position; the specified chain length is the fixed length of the chains being moved. When this length is 1, the operator simply moves a node to another position. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5, for a chain length of 2 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> 4 -> [2 -> 3] -> 5 1 -> [3 -> 4] -> 2 -> 5 Using Relocate with chain lengths of 1, 2 and 3 together is equivalent to the OrOpt operator on a path. The OrOpt operator is a limited version of 3Opt (breaks 3 arcs on a path).""" 163 RELOCATE = _pywrapcp.Solver_RELOCATE 164 r""" Relocate neighborhood with length of 1 (see OROPT comment).""" 165 EXCHANGE = _pywrapcp.Solver_EXCHANGE 166 r""" Operator which exchanges the positions of two nodes. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> [3] -> [2] -> 4 -> 5 1 -> [4] -> 3 -> [2] -> 5 1 -> 2 -> [4] -> [3] -> 5""" 167 CROSS = _pywrapcp.Solver_CROSS 168 r""" Operator which cross exchanges the starting chains of 2 paths, including exchanging the whole paths. First and last nodes are not moved. Possible neighbors for the paths 1 -> 2 -> 3 -> 4 -> 5 and 6 -> 7 -> 8 (where (1, 5) and (6, 8) are first and last nodes of the paths and can therefore not be moved): 1 -> [7] -> 3 -> 4 -> 5 6 -> [2] -> 8 1 -> [7] -> 4 -> 5 6 -> [2 -> 3] -> 8 1 -> [7] -> 5 6 -> [2 -> 3 -> 4] -> 8""" 169 MAKEACTIVE = _pywrapcp.Solver_MAKEACTIVE 170 r""" Operator which inserts an inactive node into a path. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 2 -> 3 -> 4 1 -> 2 -> [5] -> 3 -> 4 1 -> 2 -> 3 -> [5] -> 4""" 171 MAKEINACTIVE = _pywrapcp.Solver_MAKEINACTIVE 172 r""" Operator which makes path nodes inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are first and last nodes of the path) are: 1 -> 3 -> 4 with 2 inactive 1 -> 2 -> 4 with 3 inactive""" 173 MAKECHAININACTIVE = _pywrapcp.Solver_MAKECHAININACTIVE 174 r""" Operator which makes a "chain" of path nodes inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are first and last nodes of the path) are: 1 -> 3 -> 4 with 2 inactive 1 -> 2 -> 4 with 3 inactive 1 -> 4 with 2 and 3 inactive""" 175 SWAPACTIVE = _pywrapcp.Solver_SWAPACTIVE 176 r""" Operator which replaces an active node by an inactive one. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 3 -> 4 with 2 inactive 1 -> 2 -> [5] -> 4 with 3 inactive""" 177 EXTENDEDSWAPACTIVE = _pywrapcp.Solver_EXTENDEDSWAPACTIVE 178 r""" Operator which makes an inactive node active and an active one inactive. It is similar to SwapActiveOperator except that it tries to insert the inactive node in all possible positions instead of just the position of the node made inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 3 -> 4 with 2 inactive 1 -> 3 -> [5] -> 4 with 2 inactive 1 -> [5] -> 2 -> 4 with 3 inactive 1 -> 2 -> [5] -> 4 with 3 inactive""" 179 PATHLNS = _pywrapcp.Solver_PATHLNS 180 r""" Operator which relaxes two sub-chains of three consecutive arcs each. Each sub-chain is defined by a start node and the next three arcs. Those six arcs are relaxed to build a new neighbor. PATHLNS explores all possible pairs of starting nodes and so defines n^2 neighbors, n being the number of nodes. Note that the two sub-chains can be part of the same path; they even may overlap.""" 181 FULLPATHLNS = _pywrapcp.Solver_FULLPATHLNS 182 r""" Operator which relaxes one entire path and all inactive nodes, thus defining num_paths neighbors.""" 183 UNACTIVELNS = _pywrapcp.Solver_UNACTIVELNS 184 r""" Operator which relaxes all inactive nodes and one sub-chain of six consecutive arcs. That way the path can be improved by inserting inactive nodes or swapping arcs.""" 185 INCREMENT = _pywrapcp.Solver_INCREMENT 186 r""" Operator which defines one neighbor per variable. Each neighbor tries to increment by one the value of the corresponding variable. When a new solution is found the neighborhood is rebuilt from scratch, i.e., tries to increment values in the variable order. Consider for instance variables x and y. x is incremented one by one to its max, and when it is not possible to increment x anymore, y is incremented once. If this is a solution, then next neighbor tries to increment x.""" 187 DECREMENT = _pywrapcp.Solver_DECREMENT 188 r""" Operator which defines a neighborhood to decrement values. The behavior is the same as INCREMENT, except values are decremented instead of incremented.""" 189 SIMPLELNS = _pywrapcp.Solver_SIMPLELNS 190 r""" Operator which defines one neighbor per variable. Each neighbor relaxes one variable. When a new solution is found the neighborhood is rebuilt from scratch. Consider for instance variables x and y. First x is relaxed and the solver is looking for the best possible solution (with only x relaxed). Then y is relaxed, and the solver is looking for a new solution. If a new solution is found, then the next variable to be relaxed is x.""" 191 GE = _pywrapcp.Solver_GE 192 r""" Move is accepted when the current objective value >= objective.Min.""" 193 LE = _pywrapcp.Solver_LE 194 r""" Move is accepted when the current objective value <= objective.Max.""" 195 EQ = _pywrapcp.Solver_EQ 196 r""" Move is accepted when the current objective value is in the interval objective.Min .. objective.Max.""" 197 DELAYED_PRIORITY = _pywrapcp.Solver_DELAYED_PRIORITY 198 r""" DELAYED_PRIORITY is the lowest priority: Demons will be processed after VAR_PRIORITY and NORMAL_PRIORITY demons.""" 199 VAR_PRIORITY = _pywrapcp.Solver_VAR_PRIORITY 200 r""" VAR_PRIORITY is between DELAYED_PRIORITY and NORMAL_PRIORITY.""" 201 NORMAL_PRIORITY = _pywrapcp.Solver_NORMAL_PRIORITY 202 r""" NORMAL_PRIORITY is the highest priority: Demons will be processed first.""" 203 204 def __init__(self, *args): 205 _pywrapcp.Solver_swiginit(self, _pywrapcp.new_Solver(*args)) 206 207 self.__python_constraints = [] 208 209 210 211 __swig_destroy__ = _pywrapcp.delete_Solver 212 213 def Parameters(self) -> "operations_research::ConstraintSolverParameters": 214 r""" Stored Parameters.""" 215 return _pywrapcp.Solver_Parameters(self) 216 217 @staticmethod 218 def DefaultSolverParameters() -> "operations_research::ConstraintSolverParameters": 219 r""" Create a ConstraintSolverParameters proto with all the default values.""" 220 return _pywrapcp.Solver_DefaultSolverParameters() 221 222 def AddConstraint(self, c: "Constraint") -> "void": 223 r""" Adds the constraint 'c' to the model. After calling this method, and until there is a backtrack that undoes the addition, any assignment of variables to values must satisfy the given constraint in order to be considered feasible. There are two fairly different use cases: - the most common use case is modeling: the given constraint is really part of the problem that the user is trying to solve. In this use case, AddConstraint is called outside of search (i.e., with state() == OUTSIDE_SEARCH). Most users should only use AddConstraint in this way. In this case, the constraint will belong to the model forever: it cannot not be removed by backtracking. - a rarer use case is that 'c' is not a real constraint of the model. It may be a constraint generated by a branching decision (a constraint whose goal is to restrict the search space), a symmetry breaking constraint (a constraint that does restrict the search space, but in a way that cannot have an impact on the quality of the solutions in the subtree), or an inferred constraint that, while having no semantic value to the model (it does not restrict the set of solutions), is worth having because we believe it may strengthen the propagation. In these cases, it happens that the constraint is added during the search (i.e., with state() == IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is added during a search, it applies only to the subtree of the search tree rooted at the current node, and will be automatically removed by backtracking. This method does not take ownership of the constraint. If the constraint has been created by any factory method (Solver::MakeXXX), it will automatically be deleted. However, power users who implement their own constraints should do: solver.AddConstraint(solver.RevAlloc(new MyConstraint(...));""" 224 return _pywrapcp.Solver_AddConstraint(self, c) 225 226 def Solve(self, *args) -> "bool": 227 return _pywrapcp.Solver_Solve(self, *args) 228 229 def NewSearch(self, *args) -> "void": 230 return _pywrapcp.Solver_NewSearch(self, *args) 231 232 def NextSolution(self) -> "bool": 233 return _pywrapcp.Solver_NextSolution(self) 234 235 def RestartSearch(self) -> "void": 236 return _pywrapcp.Solver_RestartSearch(self) 237 238 def EndSearch(self) -> "void": 239 return _pywrapcp.Solver_EndSearch(self) 240 241 def SolveAndCommit(self, *args) -> "bool": 242 return _pywrapcp.Solver_SolveAndCommit(self, *args) 243 244 def CheckAssignment(self, solution: "Assignment") -> "bool": 245 r""" Checks whether the given assignment satisfies all relevant constraints.""" 246 return _pywrapcp.Solver_CheckAssignment(self, solution) 247 248 def CheckConstraint(self, ct: "Constraint") -> "bool": 249 r""" Checks whether adding this constraint will lead to an immediate failure. It will return false if the model is already inconsistent, or if adding the constraint makes it inconsistent.""" 250 return _pywrapcp.Solver_CheckConstraint(self, ct) 251 252 def Fail(self) -> "void": 253 r""" Abandon the current branch in the search tree. A backtrack will follow.""" 254 return _pywrapcp.Solver_Fail(self) 255 256 @staticmethod 257 def MemoryUsage() -> "int64_t": 258 r""" Current memory usage in bytes""" 259 return _pywrapcp.Solver_MemoryUsage() 260 261 def WallTime(self) -> "int64_t": 262 r""" DEPRECATED: Use Now() instead. Time elapsed, in ms since the creation of the solver.""" 263 return _pywrapcp.Solver_WallTime(self) 264 265 def Branches(self) -> "int64_t": 266 r""" The number of branches explored since the creation of the solver.""" 267 return _pywrapcp.Solver_Branches(self) 268 269 def Solutions(self) -> "int64_t": 270 r""" The number of solutions found since the start of the search.""" 271 return _pywrapcp.Solver_Solutions(self) 272 273 def Failures(self) -> "int64_t": 274 r""" The number of failures encountered since the creation of the solver.""" 275 return _pywrapcp.Solver_Failures(self) 276 277 def AcceptedNeighbors(self) -> "int64_t": 278 r""" The number of accepted neighbors.""" 279 return _pywrapcp.Solver_AcceptedNeighbors(self) 280 281 def Stamp(self) -> "uint64_t": 282 r""" The stamp indicates how many moves in the search tree we have performed. It is useful to detect if we need to update same lazy structures.""" 283 return _pywrapcp.Solver_Stamp(self) 284 285 def FailStamp(self) -> "uint64_t": 286 r""" The fail_stamp() is incremented after each backtrack.""" 287 return _pywrapcp.Solver_FailStamp(self) 288 289 def IntVar(self, *args) -> "operations_research::IntVar *": 290 r""" 291 *Overload 1:* 292 MakeIntVar will create the best range based int var for the bounds given. 293 294 | 295 296 *Overload 2:* 297 MakeIntVar will create a variable with the given sparse domain. 298 299 | 300 301 *Overload 3:* 302 MakeIntVar will create a variable with the given sparse domain. 303 304 | 305 306 *Overload 4:* 307 MakeIntVar will create the best range based int var for the bounds given. 308 309 | 310 311 *Overload 5:* 312 MakeIntVar will create a variable with the given sparse domain. 313 314 | 315 316 *Overload 6:* 317 MakeIntVar will create a variable with the given sparse domain. 318 """ 319 return _pywrapcp.Solver_IntVar(self, *args) 320 321 def BoolVar(self, *args) -> "operations_research::IntVar *": 322 r""" 323 *Overload 1:* 324 MakeBoolVar will create a variable with a {0, 1} domain. 325 326 | 327 328 *Overload 2:* 329 MakeBoolVar will create a variable with a {0, 1} domain. 330 """ 331 return _pywrapcp.Solver_BoolVar(self, *args) 332 333 def IntConst(self, *args) -> "operations_research::IntVar *": 334 r""" 335 *Overload 1:* 336 IntConst will create a constant expression. 337 338 | 339 340 *Overload 2:* 341 IntConst will create a constant expression. 342 """ 343 return _pywrapcp.Solver_IntConst(self, *args) 344 345 def Sum(self, vars: "std::vector< operations_research::IntVar * > const &") -> "operations_research::IntExpr *": 346 r""" sum of all vars.""" 347 return _pywrapcp.Solver_Sum(self, vars) 348 349 def ScalProd(self, *args) -> "operations_research::IntExpr *": 350 r""" 351 *Overload 1:* 352 scalar product 353 354 | 355 356 *Overload 2:* 357 scalar product 358 """ 359 return _pywrapcp.Solver_ScalProd(self, *args) 360 361 def MonotonicElement(self, values: "operations_research::Solver::IndexEvaluator1", increasing: "bool", index: "IntVar") -> "operations_research::IntExpr *": 362 r""" Function based element. The constraint takes ownership of the callback. The callback must be monotonic. It must be able to cope with any possible value in the domain of 'index' (potentially negative ones too). Furtermore, monotonicity is not checked. Thus giving a non-monotonic function, or specifying an incorrect increasing parameter will result in undefined behavior.""" 363 return _pywrapcp.Solver_MonotonicElement(self, values, increasing, index) 364 365 def Element(self, *args) -> "operations_research::IntExpr *": 366 r""" 367 *Overload 1:* 368 values[index] 369 370 | 371 372 *Overload 2:* 373 values[index] 374 375 | 376 377 *Overload 3:* 378 Function-based element. The constraint takes ownership of the callback. The callback must be able to cope with any possible value in the domain of 'index' (potentially negative ones too). 379 380 | 381 382 *Overload 4:* 383 2D version of function-based element expression, values(expr1, expr2). 384 385 | 386 387 *Overload 5:* 388 vars[expr] 389 """ 390 return _pywrapcp.Solver_Element(self, *args) 391 392 def IndexExpression(self, vars: "std::vector< operations_research::IntVar * > const &", value: "int64_t") -> "operations_research::IntExpr *": 393 r""" Returns the expression expr such that vars[expr] == value. It assumes that vars are all different.""" 394 return _pywrapcp.Solver_IndexExpression(self, vars, value) 395 396 def Min(self, *args) -> "operations_research::IntExpr *": 397 r""" 398 *Overload 1:* 399 std::min(vars) 400 401 | 402 403 *Overload 2:* 404 std::min (left, right) 405 406 | 407 408 *Overload 3:* 409 std::min(expr, value) 410 411 | 412 413 *Overload 4:* 414 std::min(expr, value) 415 """ 416 return _pywrapcp.Solver_Min(self, *args) 417 418 def Max(self, *args) -> "operations_research::IntExpr *": 419 r""" 420 *Overload 1:* 421 std::max(vars) 422 423 | 424 425 *Overload 2:* 426 std::max(left, right) 427 428 | 429 430 *Overload 3:* 431 std::max(expr, value) 432 433 | 434 435 *Overload 4:* 436 std::max(expr, value) 437 """ 438 return _pywrapcp.Solver_Max(self, *args) 439 440 def ConvexPiecewiseExpr(self, expr: "IntExpr", early_cost: "int64_t", early_date: "int64_t", late_date: "int64_t", late_cost: "int64_t") -> "operations_research::IntExpr *": 441 r""" Convex piecewise function.""" 442 return _pywrapcp.Solver_ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost) 443 444 def SemiContinuousExpr(self, expr: "IntExpr", fixed_charge: "int64_t", step: "int64_t") -> "operations_research::IntExpr *": 445 r""" Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b) a >= 0 and b >= 0""" 446 return _pywrapcp.Solver_SemiContinuousExpr(self, expr, fixed_charge, step) 447 448 def ConditionalExpression(self, condition: "IntVar", expr: "IntExpr", unperformed_value: "int64_t") -> "operations_research::IntExpr *": 449 r""" Conditional Expr condition ? expr : unperformed_value""" 450 return _pywrapcp.Solver_ConditionalExpression(self, condition, expr, unperformed_value) 451 452 def TrueConstraint(self) -> "operations_research::Constraint *": 453 r""" This constraint always succeeds.""" 454 return _pywrapcp.Solver_TrueConstraint(self) 455 456 def FalseConstraint(self, *args) -> "operations_research::Constraint *": 457 return _pywrapcp.Solver_FalseConstraint(self, *args) 458 459 def IsEqualCstCt(self, var: "IntExpr", value: "int64_t", boolvar: "IntVar") -> "operations_research::Constraint *": 460 r""" boolvar == (var == value)""" 461 return _pywrapcp.Solver_IsEqualCstCt(self, var, value, boolvar) 462 463 def IsEqualCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 464 r""" status var of (var == value)""" 465 return _pywrapcp.Solver_IsEqualCstVar(self, var, value) 466 467 def IsEqualCt(self, v1: "IntExpr", v2: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 468 r""" b == (v1 == v2)""" 469 return _pywrapcp.Solver_IsEqualCt(self, v1, v2, b) 470 471 def IsEqualVar(self, v1: "IntExpr", v2: "IntExpr") -> "operations_research::IntVar *": 472 r""" status var of (v1 == v2)""" 473 return _pywrapcp.Solver_IsEqualVar(self, v1, v2) 474 475 def IsDifferentCstCt(self, var: "IntExpr", value: "int64_t", boolvar: "IntVar") -> "operations_research::Constraint *": 476 r""" boolvar == (var != value)""" 477 return _pywrapcp.Solver_IsDifferentCstCt(self, var, value, boolvar) 478 479 def IsDifferentCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 480 r""" status var of (var != value)""" 481 return _pywrapcp.Solver_IsDifferentCstVar(self, var, value) 482 483 def IsDifferentVar(self, v1: "IntExpr", v2: "IntExpr") -> "operations_research::IntVar *": 484 r""" status var of (v1 != v2)""" 485 return _pywrapcp.Solver_IsDifferentVar(self, v1, v2) 486 487 def IsDifferentCt(self, v1: "IntExpr", v2: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 488 r""" b == (v1 != v2)""" 489 return _pywrapcp.Solver_IsDifferentCt(self, v1, v2, b) 490 491 def IsLessOrEqualCstCt(self, var: "IntExpr", value: "int64_t", boolvar: "IntVar") -> "operations_research::Constraint *": 492 r""" boolvar == (var <= value)""" 493 return _pywrapcp.Solver_IsLessOrEqualCstCt(self, var, value, boolvar) 494 495 def IsLessOrEqualCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 496 r""" status var of (var <= value)""" 497 return _pywrapcp.Solver_IsLessOrEqualCstVar(self, var, value) 498 499 def IsLessOrEqualVar(self, left: "IntExpr", right: "IntExpr") -> "operations_research::IntVar *": 500 r""" status var of (left <= right)""" 501 return _pywrapcp.Solver_IsLessOrEqualVar(self, left, right) 502 503 def IsLessOrEqualCt(self, left: "IntExpr", right: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 504 r""" b == (left <= right)""" 505 return _pywrapcp.Solver_IsLessOrEqualCt(self, left, right, b) 506 507 def IsGreaterOrEqualCstCt(self, var: "IntExpr", value: "int64_t", boolvar: "IntVar") -> "operations_research::Constraint *": 508 r""" boolvar == (var >= value)""" 509 return _pywrapcp.Solver_IsGreaterOrEqualCstCt(self, var, value, boolvar) 510 511 def IsGreaterOrEqualCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 512 r""" status var of (var >= value)""" 513 return _pywrapcp.Solver_IsGreaterOrEqualCstVar(self, var, value) 514 515 def IsGreaterOrEqualVar(self, left: "IntExpr", right: "IntExpr") -> "operations_research::IntVar *": 516 r""" status var of (left >= right)""" 517 return _pywrapcp.Solver_IsGreaterOrEqualVar(self, left, right) 518 519 def IsGreaterOrEqualCt(self, left: "IntExpr", right: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 520 r""" b == (left >= right)""" 521 return _pywrapcp.Solver_IsGreaterOrEqualCt(self, left, right, b) 522 523 def IsGreaterCstCt(self, v: "IntExpr", c: "int64_t", b: "IntVar") -> "operations_research::Constraint *": 524 r""" b == (v > c)""" 525 return _pywrapcp.Solver_IsGreaterCstCt(self, v, c, b) 526 527 def IsGreaterCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 528 r""" status var of (var > value)""" 529 return _pywrapcp.Solver_IsGreaterCstVar(self, var, value) 530 531 def IsGreaterVar(self, left: "IntExpr", right: "IntExpr") -> "operations_research::IntVar *": 532 r""" status var of (left > right)""" 533 return _pywrapcp.Solver_IsGreaterVar(self, left, right) 534 535 def IsGreaterCt(self, left: "IntExpr", right: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 536 r""" b == (left > right)""" 537 return _pywrapcp.Solver_IsGreaterCt(self, left, right, b) 538 539 def IsLessCstCt(self, v: "IntExpr", c: "int64_t", b: "IntVar") -> "operations_research::Constraint *": 540 r""" b == (v < c)""" 541 return _pywrapcp.Solver_IsLessCstCt(self, v, c, b) 542 543 def IsLessCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 544 r""" status var of (var < value)""" 545 return _pywrapcp.Solver_IsLessCstVar(self, var, value) 546 547 def IsLessVar(self, left: "IntExpr", right: "IntExpr") -> "operations_research::IntVar *": 548 r""" status var of (left < right)""" 549 return _pywrapcp.Solver_IsLessVar(self, left, right) 550 551 def IsLessCt(self, left: "IntExpr", right: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 552 r""" b == (left < right)""" 553 return _pywrapcp.Solver_IsLessCt(self, left, right, b) 554 555 def SumLessOrEqual(self, vars: "std::vector< operations_research::IntVar * > const &", cst: "int64_t") -> "operations_research::Constraint *": 556 r""" Variation on arrays.""" 557 return _pywrapcp.Solver_SumLessOrEqual(self, vars, cst) 558 559 def SumGreaterOrEqual(self, vars: "std::vector< operations_research::IntVar * > const &", cst: "int64_t") -> "operations_research::Constraint *": 560 return _pywrapcp.Solver_SumGreaterOrEqual(self, vars, cst) 561 562 def SumEquality(self, *args) -> "operations_research::Constraint *": 563 return _pywrapcp.Solver_SumEquality(self, *args) 564 565 def ScalProdEquality(self, *args) -> "operations_research::Constraint *": 566 return _pywrapcp.Solver_ScalProdEquality(self, *args) 567 568 def ScalProdGreaterOrEqual(self, *args) -> "operations_research::Constraint *": 569 return _pywrapcp.Solver_ScalProdGreaterOrEqual(self, *args) 570 571 def ScalProdLessOrEqual(self, *args) -> "operations_research::Constraint *": 572 return _pywrapcp.Solver_ScalProdLessOrEqual(self, *args) 573 574 def MinEquality(self, vars: "std::vector< operations_research::IntVar * > const &", min_var: "IntVar") -> "operations_research::Constraint *": 575 return _pywrapcp.Solver_MinEquality(self, vars, min_var) 576 577 def MaxEquality(self, vars: "std::vector< operations_research::IntVar * > const &", max_var: "IntVar") -> "operations_research::Constraint *": 578 return _pywrapcp.Solver_MaxEquality(self, vars, max_var) 579 580 def ElementEquality(self, *args) -> "operations_research::Constraint *": 581 return _pywrapcp.Solver_ElementEquality(self, *args) 582 583 def AbsEquality(self, var: "IntVar", abs_var: "IntVar") -> "operations_research::Constraint *": 584 r""" Creates the constraint abs(var) == abs_var.""" 585 return _pywrapcp.Solver_AbsEquality(self, var, abs_var) 586 587 def IndexOfConstraint(self, vars: "std::vector< operations_research::IntVar * > const &", index: "IntVar", target: "int64_t") -> "operations_research::Constraint *": 588 r""" This constraint is a special case of the element constraint with an array of integer variables, where the variables are all different and the index variable is constrained such that vars[index] == target.""" 589 return _pywrapcp.Solver_IndexOfConstraint(self, vars, index, target) 590 591 def ConstraintInitialPropagateCallback(self, ct: "Constraint") -> "operations_research::Demon *": 592 r""" This method is a specialized case of the MakeConstraintDemon method to call the InitiatePropagate of the constraint 'ct'.""" 593 return _pywrapcp.Solver_ConstraintInitialPropagateCallback(self, ct) 594 595 def DelayedConstraintInitialPropagateCallback(self, ct: "Constraint") -> "operations_research::Demon *": 596 r""" This method is a specialized case of the MakeConstraintDemon method to call the InitiatePropagate of the constraint 'ct' with low priority.""" 597 return _pywrapcp.Solver_DelayedConstraintInitialPropagateCallback(self, ct) 598 599 def ClosureDemon(self, closure: "operations_research::Solver::Closure") -> "operations_research::Demon *": 600 r""" Creates a demon from a closure.""" 601 return _pywrapcp.Solver_ClosureDemon(self, closure) 602 603 def BetweenCt(self, expr: "IntExpr", l: "int64_t", u: "int64_t") -> "operations_research::Constraint *": 604 r""" (l <= expr <= u)""" 605 return _pywrapcp.Solver_BetweenCt(self, expr, l, u) 606 607 def IsBetweenCt(self, expr: "IntExpr", l: "int64_t", u: "int64_t", b: "IntVar") -> "operations_research::Constraint *": 608 r""" b == (l <= expr <= u)""" 609 return _pywrapcp.Solver_IsBetweenCt(self, expr, l, u, b) 610 611 def IsBetweenVar(self, v: "IntExpr", l: "int64_t", u: "int64_t") -> "operations_research::IntVar *": 612 return _pywrapcp.Solver_IsBetweenVar(self, v, l, u) 613 614 def MemberCt(self, *args) -> "operations_research::Constraint *": 615 return _pywrapcp.Solver_MemberCt(self, *args) 616 617 def NotMemberCt(self, *args) -> "operations_research::Constraint *": 618 r""" 619 *Overload 1:* 620 expr not in set. 621 622 | 623 624 *Overload 2:* 625 expr should not be in the list of forbidden intervals [start[i]..end[i]]. 626 627 | 628 629 *Overload 3:* 630 expr should not be in the list of forbidden intervals [start[i]..end[i]]. 631 """ 632 return _pywrapcp.Solver_NotMemberCt(self, *args) 633 634 def IsMemberCt(self, *args) -> "operations_research::Constraint *": 635 return _pywrapcp.Solver_IsMemberCt(self, *args) 636 637 def IsMemberVar(self, *args) -> "operations_research::IntVar *": 638 return _pywrapcp.Solver_IsMemberVar(self, *args) 639 640 def Count(self, *args) -> "operations_research::Constraint *": 641 r""" 642 *Overload 1:* 643 |{i | vars[i] == value}| == max_count 644 645 | 646 647 *Overload 2:* 648 |{i | vars[i] == value}| == max_count 649 """ 650 return _pywrapcp.Solver_Count(self, *args) 651 652 def Distribute(self, *args) -> "operations_research::Constraint *": 653 r""" 654 *Overload 1:* 655 Aggregated version of count: |{i | v[i] == values[j]}| == cards[j] 656 657 | 658 659 *Overload 2:* 660 Aggregated version of count: |{i | v[i] == values[j]}| == cards[j] 661 662 | 663 664 *Overload 3:* 665 Aggregated version of count: |{i | v[i] == j}| == cards[j] 666 667 | 668 669 *Overload 4:* 670 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max 671 672 | 673 674 *Overload 5:* 675 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == j}| <= card_max[j] 676 677 | 678 679 *Overload 6:* 680 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == j}| <= card_max[j] 681 682 | 683 684 *Overload 7:* 685 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j] 686 687 | 688 689 *Overload 8:* 690 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j] 691 """ 692 return _pywrapcp.Solver_Distribute(self, *args) 693 694 def Deviation(self, vars: "std::vector< operations_research::IntVar * > const &", deviation_var: "IntVar", total_sum: "int64_t") -> "operations_research::Constraint *": 695 r""" Deviation constraint: sum_i |n * vars[i] - total_sum| <= deviation_var and sum_i vars[i] == total_sum n = #vars""" 696 return _pywrapcp.Solver_Deviation(self, vars, deviation_var, total_sum) 697 698 def AllDifferent(self, *args) -> "operations_research::Constraint *": 699 r""" 700 *Overload 1:* 701 All variables are pairwise different. This corresponds to the stronger version of the propagation algorithm. 702 703 | 704 705 *Overload 2:* 706 All variables are pairwise different. If 'stronger_propagation' is true, stronger, and potentially slower propagation will occur. This API will be deprecated in the future. 707 """ 708 return _pywrapcp.Solver_AllDifferent(self, *args) 709 710 def AllDifferentExcept(self, vars: "std::vector< operations_research::IntVar * > const &", escape_value: "int64_t") -> "operations_research::Constraint *": 711 r""" All variables are pairwise different, unless they are assigned to the escape value.""" 712 return _pywrapcp.Solver_AllDifferentExcept(self, vars, escape_value) 713 714 def SortingConstraint(self, vars: "std::vector< operations_research::IntVar * > const &", sorted: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 715 r""" Creates a constraint binding the arrays of variables "vars" and "sorted_vars": sorted_vars[0] must be equal to the minimum of all variables in vars, and so on: the value of sorted_vars[i] must be equal to the i-th value of variables invars. This constraint propagates in both directions: from "vars" to "sorted_vars" and vice-versa. Behind the scenes, this constraint maintains that: - sorted is always increasing. - whatever the values of vars, there exists a permutation that injects its values into the sorted variables. For more info, please have a look at: https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf""" 716 return _pywrapcp.Solver_SortingConstraint(self, vars, sorted) 717 718 def LexicalLess(self, left: "std::vector< operations_research::IntVar * > const &", right: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 719 r""" Creates a constraint that enforces that left is lexicographically less than right.""" 720 return _pywrapcp.Solver_LexicalLess(self, left, right) 721 722 def LexicalLessOrEqual(self, left: "std::vector< operations_research::IntVar * > const &", right: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 723 r""" Creates a constraint that enforces that left is lexicographically less than or equal to right.""" 724 return _pywrapcp.Solver_LexicalLessOrEqual(self, left, right) 725 726 def InversePermutationConstraint(self, left: "std::vector< operations_research::IntVar * > const &", right: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 727 r""" Creates a constraint that enforces that 'left' and 'right' both represent permutations of [0..left.size()-1], and that 'right' is the inverse permutation of 'left', i.e. for all i in [0..left.size()-1], right[left[i]] = i.""" 728 return _pywrapcp.Solver_InversePermutationConstraint(self, left, right) 729 730 def NullIntersect(self, first_vars: "std::vector< operations_research::IntVar * > const &", second_vars: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 731 r""" Creates a constraint that states that all variables in the first vector are different from all variables in the second group. Thus the set of values in the first vector does not intersect with the set of values in the second vector.""" 732 return _pywrapcp.Solver_NullIntersect(self, first_vars, second_vars) 733 734 def NullIntersectExcept(self, first_vars: "std::vector< operations_research::IntVar * > const &", second_vars: "std::vector< operations_research::IntVar * > const &", escape_value: "int64_t") -> "operations_research::Constraint *": 735 r""" Creates a constraint that states that all variables in the first vector are different from all variables from the second group, unless they are assigned to the escape value. Thus the set of values in the first vector minus the escape value does not intersect with the set of values in the second vector.""" 736 return _pywrapcp.Solver_NullIntersectExcept(self, first_vars, second_vars, escape_value) 737 738 def Circuit(self, nexts: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 739 r""" Force the "nexts" variable to create a complete Hamiltonian path.""" 740 return _pywrapcp.Solver_Circuit(self, nexts) 741 742 def SubCircuit(self, nexts: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 743 r""" Force the "nexts" variable to create a complete Hamiltonian path for those that do not loop upon themselves.""" 744 return _pywrapcp.Solver_SubCircuit(self, nexts) 745 746 def DelayedPathCumul(self, nexts: "std::vector< operations_research::IntVar * > const &", active: "std::vector< operations_research::IntVar * > const &", cumuls: "std::vector< operations_research::IntVar * > const &", transits: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 747 r""" Delayed version of the same constraint: propagation on the nexts variables is delayed until all constraints have propagated.""" 748 return _pywrapcp.Solver_DelayedPathCumul(self, nexts, active, cumuls, transits) 749 750 def PathCumul(self, *args) -> "operations_research::Constraint *": 751 r""" 752 *Overload 1:* 753 Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transits[i]. Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. 754 755 | 756 757 *Overload 2:* 758 Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]). Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. Ownership of transit_evaluator is taken and it must be a repeatable callback. 759 760 | 761 762 *Overload 3:* 763 Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i]. Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. Ownership of transit_evaluator is taken and it must be a repeatable callback. 764 """ 765 return _pywrapcp.Solver_PathCumul(self, *args) 766 767 def AllowedAssignments(self, *args) -> "operations_research::Constraint *": 768 r""" 769 *Overload 1:* 770 This method creates a constraint where the graph of the relation between the variables is given in extension. There are 'arity' variables involved in the relation and the graph is given by a integer tuple set. 771 772 | 773 774 *Overload 2:* 775 Compatibility layer for Python API. 776 """ 777 return _pywrapcp.Solver_AllowedAssignments(self, *args) 778 779 def TransitionConstraint(self, *args) -> "operations_research::Constraint *": 780 return _pywrapcp.Solver_TransitionConstraint(self, *args) 781 782 def NonOverlappingBoxesConstraint(self, *args) -> "operations_research::Constraint *": 783 return _pywrapcp.Solver_NonOverlappingBoxesConstraint(self, *args) 784 785 def Pack(self, vars: "std::vector< operations_research::IntVar * > const &", number_of_bins: "int") -> "operations_research::Pack *": 786 r""" This constraint packs all variables onto 'number_of_bins' variables. For any given variable, a value of 'number_of_bins' indicates that the variable is not assigned to any bin. Dimensions, i.e., cumulative constraints on this packing, can be added directly from the pack class.""" 787 return _pywrapcp.Solver_Pack(self, vars, number_of_bins) 788 789 def FixedDurationIntervalVar(self, *args) -> "operations_research::IntervalVar *": 790 r""" 791 *Overload 1:* 792 Creates an interval var with a fixed duration. The duration must be greater than 0. If optional is true, then the interval can be performed or unperformed. If optional is false, then the interval is always performed. 793 794 | 795 796 *Overload 2:* 797 Creates a performed interval var with a fixed duration. The duration must be greater than 0. 798 799 | 800 801 *Overload 3:* 802 Creates an interval var with a fixed duration, and performed_variable. The duration must be greater than 0. 803 """ 804 return _pywrapcp.Solver_FixedDurationIntervalVar(self, *args) 805 806 def FixedInterval(self, start: "int64_t", duration: "int64_t", name: "std::string const &") -> "operations_research::IntervalVar *": 807 r""" Creates a fixed and performed interval.""" 808 return _pywrapcp.Solver_FixedInterval(self, start, duration, name) 809 810 def IntervalVar(self, start_min: "int64_t", start_max: "int64_t", duration_min: "int64_t", duration_max: "int64_t", end_min: "int64_t", end_max: "int64_t", optional: "bool", name: "std::string const &") -> "operations_research::IntervalVar *": 811 r""" Creates an interval var by specifying the bounds on start, duration, and end.""" 812 return _pywrapcp.Solver_IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name) 813 814 def MirrorInterval(self, interval_var: "IntervalVar") -> "operations_research::IntervalVar *": 815 r""" Creates an interval var that is the mirror image of the given one, that is, the interval var obtained by reversing the axis.""" 816 return _pywrapcp.Solver_MirrorInterval(self, interval_var) 817 818 def FixedDurationStartSyncedOnStartIntervalVar(self, interval_var: "IntervalVar", duration: "int64_t", offset: "int64_t") -> "operations_research::IntervalVar *": 819 r""" Creates an interval var with a fixed duration whose start is synchronized with the start of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.""" 820 return _pywrapcp.Solver_FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset) 821 822 def FixedDurationStartSyncedOnEndIntervalVar(self, interval_var: "IntervalVar", duration: "int64_t", offset: "int64_t") -> "operations_research::IntervalVar *": 823 r""" Creates an interval var with a fixed duration whose start is synchronized with the end of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.""" 824 return _pywrapcp.Solver_FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset) 825 826 def FixedDurationEndSyncedOnStartIntervalVar(self, interval_var: "IntervalVar", duration: "int64_t", offset: "int64_t") -> "operations_research::IntervalVar *": 827 r""" Creates an interval var with a fixed duration whose end is synchronized with the start of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.""" 828 return _pywrapcp.Solver_FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset) 829 830 def FixedDurationEndSyncedOnEndIntervalVar(self, interval_var: "IntervalVar", duration: "int64_t", offset: "int64_t") -> "operations_research::IntervalVar *": 831 r""" Creates an interval var with a fixed duration whose end is synchronized with the end of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.""" 832 return _pywrapcp.Solver_FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset) 833 834 def IntervalRelaxedMin(self, interval_var: "IntervalVar") -> "operations_research::IntervalVar *": 835 r""" Creates and returns an interval variable that wraps around the given one, relaxing the min start and end. Relaxing means making unbounded when optional. If the variable is non-optional, this method returns interval_var. More precisely, such an interval variable behaves as follows: * When the underlying must be performed, the returned interval variable behaves exactly as the underlying; * When the underlying may or may not be performed, the returned interval variable behaves like the underlying, except that it is unbounded on the min side; * When the underlying cannot be performed, the returned interval variable is of duration 0 and must be performed in an interval unbounded on both sides. This is very useful to implement propagators that may only modify the start max or end max.""" 836 return _pywrapcp.Solver_IntervalRelaxedMin(self, interval_var) 837 838 def IntervalRelaxedMax(self, interval_var: "IntervalVar") -> "operations_research::IntervalVar *": 839 r""" Creates and returns an interval variable that wraps around the given one, relaxing the max start and end. Relaxing means making unbounded when optional. If the variable is non optional, this method returns interval_var. More precisely, such an interval variable behaves as follows: * When the underlying must be performed, the returned interval variable behaves exactly as the underlying; * When the underlying may or may not be performed, the returned interval variable behaves like the underlying, except that it is unbounded on the max side; * When the underlying cannot be performed, the returned interval variable is of duration 0 and must be performed in an interval unbounded on both sides. This is very useful for implementing propagators that may only modify the start min or end min.""" 840 return _pywrapcp.Solver_IntervalRelaxedMax(self, interval_var) 841 842 def TemporalDisjunction(self, *args) -> "operations_research::Constraint *": 843 r""" 844 *Overload 1:* 845 This constraint implements a temporal disjunction between two interval vars t1 and t2. 'alt' indicates which alternative was chosen (alt == 0 is equivalent to t1 before t2). 846 847 | 848 849 *Overload 2:* 850 This constraint implements a temporal disjunction between two interval vars. 851 """ 852 return _pywrapcp.Solver_TemporalDisjunction(self, *args) 853 854 def DisjunctiveConstraint(self, intervals: "std::vector< operations_research::IntervalVar * > const &", name: "std::string const &") -> "operations_research::DisjunctiveConstraint *": 855 r""" This constraint forces all interval vars into an non-overlapping sequence. Intervals with zero duration can be scheduled anywhere.""" 856 return _pywrapcp.Solver_DisjunctiveConstraint(self, intervals, name) 857 858 def Cumulative(self, *args) -> "operations_research::Constraint *": 859 r""" 860 *Overload 1:* 861 This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint. 862 863 | 864 865 *Overload 2:* 866 This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint. 867 868 | 869 870 *Overload 3:* 871 This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint. 872 873 | 874 875 *Overload 4:* 876 This constraint enforces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint. 877 878 | 879 880 *Overload 5:* 881 This constraint enforces that, for any integer t, the sum of demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should be positive. 882 883 | 884 885 *Overload 6:* 886 This constraint enforces that, for any integer t, the sum of demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should be positive. 887 """ 888 return _pywrapcp.Solver_Cumulative(self, *args) 889 890 def Cover(self, vars: "std::vector< operations_research::IntervalVar * > const &", target_var: "IntervalVar") -> "operations_research::Constraint *": 891 r""" This constraint states that the target_var is the convex hull of the intervals. If none of the interval variables is performed, then the target var is unperformed too. Also, if the target variable is unperformed, then all the intervals variables are unperformed too.""" 892 return _pywrapcp.Solver_Cover(self, vars, target_var) 893 894 def Assignment(self, *args) -> "operations_research::Assignment *": 895 r""" 896 *Overload 1:* 897 This method creates an empty assignment. 898 899 | 900 901 *Overload 2:* 902 This method creates an assignment which is a copy of 'a'. 903 """ 904 return _pywrapcp.Solver_Assignment(self, *args) 905 906 def FirstSolutionCollector(self, *args) -> "operations_research::SolutionCollector *": 907 r""" 908 *Overload 1:* 909 Collect the first solution of the search. 910 911 | 912 913 *Overload 2:* 914 Collect the first solution of the search. The variables will need to be added later. 915 """ 916 return _pywrapcp.Solver_FirstSolutionCollector(self, *args) 917 918 def LastSolutionCollector(self, *args) -> "operations_research::SolutionCollector *": 919 r""" 920 *Overload 1:* 921 Collect the last solution of the search. 922 923 | 924 925 *Overload 2:* 926 Collect the last solution of the search. The variables will need to be added later. 927 """ 928 return _pywrapcp.Solver_LastSolutionCollector(self, *args) 929 930 def BestValueSolutionCollector(self, *args) -> "operations_research::SolutionCollector *": 931 r""" 932 *Overload 1:* 933 Collect the solution corresponding to the optimal value of the objective of 'assignment'; if 'assignment' does not have an objective no solution is collected. This collector only collects one solution corresponding to the best objective value (the first one found). 934 935 | 936 937 *Overload 2:* 938 Collect the solution corresponding to the optimal value of the objective of 'assignment'; if 'assignment' does not have an objective no solution is collected. This collector only collects one solution corresponding to the best objective value (the first one found). The variables will need to be added later. 939 """ 940 return _pywrapcp.Solver_BestValueSolutionCollector(self, *args) 941 942 def AllSolutionCollector(self, *args) -> "operations_research::SolutionCollector *": 943 r""" 944 *Overload 1:* 945 Collect all solutions of the search. 946 947 | 948 949 *Overload 2:* 950 Collect all solutions of the search. The variables will need to be added later. 951 """ 952 return _pywrapcp.Solver_AllSolutionCollector(self, *args) 953 954 def Minimize(self, v: "IntVar", step: "int64_t") -> "operations_research::OptimizeVar *": 955 r""" Creates a minimization objective.""" 956 return _pywrapcp.Solver_Minimize(self, v, step) 957 958 def Maximize(self, v: "IntVar", step: "int64_t") -> "operations_research::OptimizeVar *": 959 r""" Creates a maximization objective.""" 960 return _pywrapcp.Solver_Maximize(self, v, step) 961 962 def Optimize(self, maximize: "bool", v: "IntVar", step: "int64_t") -> "operations_research::OptimizeVar *": 963 r""" Creates a objective with a given sense (true = maximization).""" 964 return _pywrapcp.Solver_Optimize(self, maximize, v, step) 965 966 def WeightedMinimize(self, *args) -> "operations_research::OptimizeVar *": 967 r""" 968 *Overload 1:* 969 Creates a minimization weighted objective. The actual objective is scalar_prod(sub_objectives, weights). 970 971 | 972 973 *Overload 2:* 974 Creates a minimization weighted objective. The actual objective is scalar_prod(sub_objectives, weights). 975 """ 976 return _pywrapcp.Solver_WeightedMinimize(self, *args) 977 978 def WeightedMaximize(self, *args) -> "operations_research::OptimizeVar *": 979 r""" 980 *Overload 1:* 981 Creates a maximization weigthed objective. 982 983 | 984 985 *Overload 2:* 986 Creates a maximization weigthed objective. 987 """ 988 return _pywrapcp.Solver_WeightedMaximize(self, *args) 989 990 def WeightedOptimize(self, *args) -> "operations_research::OptimizeVar *": 991 r""" 992 *Overload 1:* 993 Creates a weighted objective with a given sense (true = maximization). 994 995 | 996 997 *Overload 2:* 998 Creates a weighted objective with a given sense (true = maximization). 999 """ 1000 return _pywrapcp.Solver_WeightedOptimize(self, *args) 1001 1002 def TabuSearch(self, maximize: "bool", v: "IntVar", step: "int64_t", vars: "std::vector< operations_research::IntVar * > const &", keep_tenure: "int64_t", forbid_tenure: "int64_t", tabu_factor: "double") -> "operations_research::SearchMonitor *": 1003 r""" MetaHeuristics which try to get the search out of local optima. Creates a Tabu Search monitor. In the context of local search the behavior is similar to MakeOptimize(), creating an objective in a given sense. The behavior differs once a local optimum is reached: thereafter solutions which degrade the value of the objective are allowed if they are not "tabu". A solution is "tabu" if it doesn't respect the following rules: - improving the best solution found so far - variables in the "keep" list must keep their value, variables in the "forbid" list must not take the value they have in the list. Variables with new values enter the tabu lists after each new solution found and leave the lists after a given number of iterations (called tenure). Only the variables passed to the method can enter the lists. The tabu criterion is softened by the tabu factor which gives the number of "tabu" violations which is tolerated; a factor of 1 means no violations allowed; a factor of 0 means all violations are allowed.""" 1004 return _pywrapcp.Solver_TabuSearch(self, maximize, v, step, vars, keep_tenure, forbid_tenure, tabu_factor) 1005 1006 def SimulatedAnnealing(self, maximize: "bool", v: "IntVar", step: "int64_t", initial_temperature: "int64_t") -> "operations_research::SearchMonitor *": 1007 r""" Creates a Simulated Annealing monitor.""" 1008 return _pywrapcp.Solver_SimulatedAnnealing(self, maximize, v, step, initial_temperature) 1009 1010 def LubyRestart(self, scale_factor: "int") -> "operations_research::SearchMonitor *": 1011 r""" This search monitor will restart the search periodically. At the iteration n, it will restart after scale_factor * Luby(n) failures where Luby is the Luby Strategy (i.e. 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8...).""" 1012 return _pywrapcp.Solver_LubyRestart(self, scale_factor) 1013 1014 def ConstantRestart(self, frequency: "int") -> "operations_research::SearchMonitor *": 1015 r""" This search monitor will restart the search periodically after 'frequency' failures.""" 1016 return _pywrapcp.Solver_ConstantRestart(self, frequency) 1017 1018 def TimeLimit(self, *args) -> "operations_research::RegularLimit *": 1019 return _pywrapcp.Solver_TimeLimit(self, *args) 1020 1021 def BranchesLimit(self, branches: "int64_t") -> "operations_research::RegularLimit *": 1022 r""" Creates a search limit that constrains the number of branches explored in the search tree.""" 1023 return _pywrapcp.Solver_BranchesLimit(self, branches) 1024 1025 def FailuresLimit(self, failures: "int64_t") -> "operations_research::RegularLimit *": 1026 r""" Creates a search limit that constrains the number of failures that can happen when exploring the search tree.""" 1027 return _pywrapcp.Solver_FailuresLimit(self, failures) 1028 1029 def SolutionsLimit(self, solutions: "int64_t") -> "operations_research::RegularLimit *": 1030 r""" Creates a search limit that constrains the number of solutions found during the search.""" 1031 return _pywrapcp.Solver_SolutionsLimit(self, solutions) 1032 1033 def Limit(self, *args) -> "operations_research::SearchLimit *": 1034 r""" 1035 *Overload 1:* 1036 Limits the search with the 'time', 'branches', 'failures' and 'solutions' limits. 'smart_time_check' reduces the calls to the wall 1037 1038 | 1039 1040 *Overload 2:* 1041 Creates a search limit from its protobuf description 1042 1043 | 1044 1045 *Overload 3:* 1046 Creates a search limit that is reached when either of the underlying limit is reached. That is, the returned limit is more stringent than both argument limits. 1047 """ 1048 return _pywrapcp.Solver_Limit(self, *args) 1049 1050 def CustomLimit(self, limiter: "std::function< bool () >") -> "operations_research::SearchLimit *": 1051 r""" Callback-based search limit. Search stops when limiter returns true; if this happens at a leaf the corresponding solution will be rejected.""" 1052 return _pywrapcp.Solver_CustomLimit(self, limiter) 1053 1054 def SearchLog(self, *args) -> "operations_research::SearchMonitor *": 1055 return _pywrapcp.Solver_SearchLog(self, *args) 1056 1057 def SearchTrace(self, prefix: "std::string const &") -> "operations_research::SearchMonitor *": 1058 r""" Creates a search monitor that will trace precisely the behavior of the search. Use this only for low level debugging.""" 1059 return _pywrapcp.Solver_SearchTrace(self, prefix) 1060 1061 def PrintModelVisitor(self) -> "operations_research::ModelVisitor *": 1062 r""" Prints the model.""" 1063 return _pywrapcp.Solver_PrintModelVisitor(self) 1064 1065 def StatisticsModelVisitor(self) -> "operations_research::ModelVisitor *": 1066 r""" Displays some nice statistics on the model.""" 1067 return _pywrapcp.Solver_StatisticsModelVisitor(self) 1068 1069 def AssignVariableValue(self, var: "IntVar", val: "int64_t") -> "operations_research::Decision *": 1070 r""" Decisions.""" 1071 return _pywrapcp.Solver_AssignVariableValue(self, var, val) 1072 1073 def VariableLessOrEqualValue(self, var: "IntVar", value: "int64_t") -> "operations_research::Decision *": 1074 return _pywrapcp.Solver_VariableLessOrEqualValue(self, var, value) 1075 1076 def VariableGreaterOrEqualValue(self, var: "IntVar", value: "int64_t") -> "operations_research::Decision *": 1077 return _pywrapcp.Solver_VariableGreaterOrEqualValue(self, var, value) 1078 1079 def SplitVariableDomain(self, var: "IntVar", val: "int64_t", start_with_lower_half: "bool") -> "operations_research::Decision *": 1080 return _pywrapcp.Solver_SplitVariableDomain(self, var, val, start_with_lower_half) 1081 1082 def AssignVariableValueOrFail(self, var: "IntVar", value: "int64_t") -> "operations_research::Decision *": 1083 return _pywrapcp.Solver_AssignVariableValueOrFail(self, var, value) 1084 1085 def AssignVariablesValues(self, vars: "std::vector< operations_research::IntVar * > const &", values: "std::vector< int64_t > const &") -> "operations_research::Decision *": 1086 return _pywrapcp.Solver_AssignVariablesValues(self, vars, values) 1087 1088 def FailDecision(self) -> "operations_research::Decision *": 1089 return _pywrapcp.Solver_FailDecision(self) 1090 1091 def Decision(self, apply: "operations_research::Solver::Action", refute: "operations_research::Solver::Action") -> "operations_research::Decision *": 1092 return _pywrapcp.Solver_Decision(self, apply, refute) 1093 1094 def Compose(self, dbs: "std::vector< operations_research::DecisionBuilder * > const &") -> "operations_research::DecisionBuilder *": 1095 return _pywrapcp.Solver_Compose(self, dbs) 1096 1097 def Try(self, dbs: "std::vector< operations_research::DecisionBuilder * > const &") -> "operations_research::DecisionBuilder *": 1098 return _pywrapcp.Solver_Try(self, dbs) 1099 1100 def DefaultPhase(self, *args) -> "operations_research::DecisionBuilder *": 1101 return _pywrapcp.Solver_DefaultPhase(self, *args) 1102 1103 def ScheduleOrPostpone(self, var: "IntervalVar", est: "int64_t", marker: "int64_t *const") -> "operations_research::Decision *": 1104 r""" Returns a decision that tries to schedule a task at a given time. On the Apply branch, it will set that interval var as performed and set its start to 'est'. On the Refute branch, it will just update the 'marker' to 'est' + 1. This decision is used in the INTERVAL_SET_TIMES_FORWARD strategy.""" 1105 return _pywrapcp.Solver_ScheduleOrPostpone(self, var, est, marker) 1106 1107 def ScheduleOrExpedite(self, var: "IntervalVar", est: "int64_t", marker: "int64_t *const") -> "operations_research::Decision *": 1108 r""" Returns a decision that tries to schedule a task at a given time. On the Apply branch, it will set that interval var as performed and set its end to 'est'. On the Refute branch, it will just update the 'marker' to 'est' - 1. This decision is used in the INTERVAL_SET_TIMES_BACKWARD strategy.""" 1109 return _pywrapcp.Solver_ScheduleOrExpedite(self, var, est, marker) 1110 1111 def RankFirstInterval(self, sequence: "SequenceVar", index: "int") -> "operations_research::Decision *": 1112 r""" Returns a decision that tries to rank first the ith interval var in the sequence variable.""" 1113 return _pywrapcp.Solver_RankFirstInterval(self, sequence, index) 1114 1115 def RankLastInterval(self, sequence: "SequenceVar", index: "int") -> "operations_research::Decision *": 1116 r""" Returns a decision that tries to rank last the ith interval var in the sequence variable.""" 1117 return _pywrapcp.Solver_RankLastInterval(self, sequence, index) 1118 1119 def Phase(self, *args) -> "operations_research::DecisionBuilder *": 1120 return _pywrapcp.Solver_Phase(self, *args) 1121 1122 def DecisionBuilderFromAssignment(self, assignment: "Assignment", db: "DecisionBuilder", vars: "std::vector< operations_research::IntVar * > const &") -> "operations_research::DecisionBuilder *": 1123 r""" Returns a decision builder for which the left-most leaf corresponds to assignment, the rest of the tree being explored using 'db'.""" 1124 return _pywrapcp.Solver_DecisionBuilderFromAssignment(self, assignment, db, vars) 1125 1126 def ConstraintAdder(self, ct: "Constraint") -> "operations_research::DecisionBuilder *": 1127 r""" Returns a decision builder that will add the given constraint to the model.""" 1128 return _pywrapcp.Solver_ConstraintAdder(self, ct) 1129 1130 def SolveOnce(self, db: "DecisionBuilder", monitors: "std::vector< operations_research::SearchMonitor * > const &") -> "operations_research::DecisionBuilder *": 1131 return _pywrapcp.Solver_SolveOnce(self, db, monitors) 1132 1133 def NestedOptimize(self, *args) -> "operations_research::DecisionBuilder *": 1134 return _pywrapcp.Solver_NestedOptimize(self, *args) 1135 1136 def RestoreAssignment(self, assignment: "Assignment") -> "operations_research::DecisionBuilder *": 1137 r""" Returns a DecisionBuilder which restores an Assignment (calls void Assignment::Restore())""" 1138 return _pywrapcp.Solver_RestoreAssignment(self, assignment) 1139 1140 def StoreAssignment(self, assignment: "Assignment") -> "operations_research::DecisionBuilder *": 1141 r""" Returns a DecisionBuilder which stores an Assignment (calls void Assignment::Store())""" 1142 return _pywrapcp.Solver_StoreAssignment(self, assignment) 1143 1144 def Operator(self, *args) -> "operations_research::LocalSearchOperator *": 1145 return _pywrapcp.Solver_Operator(self, *args) 1146 1147 def RandomLnsOperator(self, *args) -> "operations_research::LocalSearchOperator *": 1148 return _pywrapcp.Solver_RandomLnsOperator(self, *args) 1149 1150 def MoveTowardTargetOperator(self, *args) -> "operations_research::LocalSearchOperator *": 1151 r""" 1152 *Overload 1:* 1153 Creates a local search operator that tries to move the assignment of some variables toward a target. The target is given as an Assignment. This operator generates neighbors in which the only difference compared to the current state is that one variable that belongs to the target assignment is set to its target value. 1154 1155 | 1156 1157 *Overload 2:* 1158 Creates a local search operator that tries to move the assignment of some variables toward a target. The target is given either as two vectors: a vector of variables and a vector of associated target values. The two vectors should be of the same length. This operator generates neighbors in which the only difference compared to the current state is that one variable that belongs to the given vector is set to its target value. 1159 """ 1160 return _pywrapcp.Solver_MoveTowardTargetOperator(self, *args) 1161 1162 def ConcatenateOperators(self, *args) -> "operations_research::LocalSearchOperator *": 1163 return _pywrapcp.Solver_ConcatenateOperators(self, *args) 1164 1165 def RandomConcatenateOperators(self, *args) -> "operations_research::LocalSearchOperator *": 1166 r""" 1167 *Overload 1:* 1168 Randomized version of local search concatenator; calls a random operator at each call to MakeNextNeighbor(). 1169 1170 | 1171 1172 *Overload 2:* 1173 Randomized version of local search concatenator; calls a random operator at each call to MakeNextNeighbor(). The provided seed is used to initialize the random number generator. 1174 """ 1175 return _pywrapcp.Solver_RandomConcatenateOperators(self, *args) 1176 1177 def NeighborhoodLimit(self, op: "LocalSearchOperator", limit: "int64_t") -> "operations_research::LocalSearchOperator *": 1178 r""" Creates a local search operator that wraps another local search operator and limits the number of neighbors explored (i.e., calls to MakeNextNeighbor from the current solution (between two calls to Start()). When this limit is reached, MakeNextNeighbor() returns false. The counter is cleared when Start() is called.""" 1179 return _pywrapcp.Solver_NeighborhoodLimit(self, op, limit) 1180 1181 def LocalSearchPhase(self, *args) -> "operations_research::DecisionBuilder *": 1182 return _pywrapcp.Solver_LocalSearchPhase(self, *args) 1183 1184 def LocalSearchPhaseParameters(self, *args) -> "operations_research::LocalSearchPhaseParameters *": 1185 return _pywrapcp.Solver_LocalSearchPhaseParameters(self, *args) 1186 1187 def SearchDepth(self) -> "int": 1188 r""" Gets the search depth of the current active search. Returns -1 if there is no active search opened.""" 1189 return _pywrapcp.Solver_SearchDepth(self) 1190 1191 def SearchLeftDepth(self) -> "int": 1192 r""" Gets the search left depth of the current active search. Returns -1 if there is no active search opened.""" 1193 return _pywrapcp.Solver_SearchLeftDepth(self) 1194 1195 def SolveDepth(self) -> "int": 1196 r""" Gets the number of nested searches. It returns 0 outside search, 1 during the top level search, 2 or more in case of nested searches.""" 1197 return _pywrapcp.Solver_SolveDepth(self) 1198 1199 def Rand64(self, size: "int64_t") -> "int64_t": 1200 r""" Returns a random value between 0 and 'size' - 1;""" 1201 return _pywrapcp.Solver_Rand64(self, size) 1202 1203 def Rand32(self, size: "int32_t") -> "int32_t": 1204 r""" Returns a random value between 0 and 'size' - 1;""" 1205 return _pywrapcp.Solver_Rand32(self, size) 1206 1207 def ReSeed(self, seed: "int32_t") -> "void": 1208 r""" Reseed the solver random generator.""" 1209 return _pywrapcp.Solver_ReSeed(self, seed) 1210 1211 def LocalSearchProfile(self) -> "std::string": 1212 r""" Returns local search profiling information in a human readable format.""" 1213 return _pywrapcp.Solver_LocalSearchProfile(self) 1214 1215 def Constraints(self) -> "int": 1216 r""" Counts the number of constraints that have been added to the solver before the search.""" 1217 return _pywrapcp.Solver_Constraints(self) 1218 1219 def Accept(self, visitor: "operations_research::ModelVisitor *const") -> "void": 1220 r""" Accepts the given model visitor.""" 1221 return _pywrapcp.Solver_Accept(self, visitor) 1222 1223 def FinishCurrentSearch(self) -> "void": 1224 r""" Tells the solver to kill or restart the current search.""" 1225 return _pywrapcp.Solver_FinishCurrentSearch(self) 1226 1227 def RestartCurrentSearch(self) -> "void": 1228 return _pywrapcp.Solver_RestartCurrentSearch(self) 1229 1230 def ShouldFail(self) -> "void": 1231 r""" These methods are only useful for the SWIG wrappers, which need a way to externally cause the Solver to fail.""" 1232 return _pywrapcp.Solver_ShouldFail(self) 1233 1234 def __str__(self) -> "std::string": 1235 return _pywrapcp.Solver___str__(self) 1236 1237 def Add(self, ct): 1238 if isinstance(ct, PyConstraint): 1239 self.__python_constraints.append(ct) 1240 self.AddConstraint(ct) 1241 1242 1243 def TreeNoCycle(self, nexts: "std::vector< operations_research::IntVar * > const &", active: "std::vector< operations_research::IntVar * > const &", callback: "operations_research::Solver::IndexFilter1"=0) -> "operations_research::Constraint *": 1244 return _pywrapcp.Solver_TreeNoCycle(self, nexts, active, callback) 1245 1246 def SearchLogWithCallback(self, period: "int", callback: "std::function< std::string () >") -> "operations_research::SearchMonitor *": 1247 return _pywrapcp.Solver_SearchLogWithCallback(self, period, callback) 1248 1249 def ElementFunction(self, values: "std::function< int64_t (int64_t) >", index: "IntVar") -> "operations_research::IntExpr *": 1250 return _pywrapcp.Solver_ElementFunction(self, values, index) 1251 1252 def VarEvalValStrPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_evaluator: "std::function< int64_t (int64_t) >", val_str: "operations_research::Solver::IntValueStrategy") -> "operations_research::DecisionBuilder *": 1253 return _pywrapcp.Solver_VarEvalValStrPhase(self, vars, var_evaluator, val_str) 1254 1255 def VarStrValEvalPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_str: "operations_research::Solver::IntVarStrategy", val_eval: "operations_research::Solver::IndexEvaluator2") -> "operations_research::DecisionBuilder *": 1256 return _pywrapcp.Solver_VarStrValEvalPhase(self, vars, var_str, val_eval) 1257 1258 def VarEvalValEvalPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_eval: "std::function< int64_t (int64_t) >", val_eval: "operations_research::Solver::IndexEvaluator2") -> "operations_research::DecisionBuilder *": 1259 return _pywrapcp.Solver_VarEvalValEvalPhase(self, vars, var_eval, val_eval) 1260 1261 def VarStrValEvalTieBreakPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_str: "operations_research::Solver::IntVarStrategy", val_eval: "operations_research::Solver::IndexEvaluator2", tie_breaker: "std::function< int64_t (int64_t) >") -> "operations_research::DecisionBuilder *": 1262 return _pywrapcp.Solver_VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker) 1263 1264 def VarEvalValEvalTieBreakPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_eval: "std::function< int64_t (int64_t) >", val_eval: "operations_research::Solver::IndexEvaluator2", tie_breaker: "std::function< int64_t (int64_t) >") -> "operations_research::DecisionBuilder *": 1265 return _pywrapcp.Solver_VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker) 1266 1267 def EvalEvalStrPhase(self, vars: "std::vector< operations_research::IntVar * > const &", evaluator: "operations_research::Solver::IndexEvaluator2", str: "operations_research::Solver::EvaluatorStrategy") -> "operations_research::DecisionBuilder *": 1268 return _pywrapcp.Solver_EvalEvalStrPhase(self, vars, evaluator, str) 1269 1270 def EvalEvalStrTieBreakPhase(self, vars: "std::vector< operations_research::IntVar * > const &", evaluator: "operations_research::Solver::IndexEvaluator2", tie_breaker: "operations_research::Solver::IndexEvaluator1", str: "operations_research::Solver::EvaluatorStrategy") -> "operations_research::DecisionBuilder *": 1271 return _pywrapcp.Solver_EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str) 1272 1273 def GuidedLocalSearch(self, *args) -> "operations_research::SearchMonitor *": 1274 return _pywrapcp.Solver_GuidedLocalSearch(self, *args) 1275 1276 def SumObjectiveFilter(self, vars: "std::vector< operations_research::IntVar * > const &", values: "operations_research::Solver::IndexEvaluator2", filter_enum: "operations_research::Solver::LocalSearchFilterBound") -> "operations_research::LocalSearchFilter *": 1277 return _pywrapcp.Solver_SumObjectiveFilter(self, vars, values, filter_enum)
Solver Class A solver represents the main computation engine. It implements the entire range of Constraint Programming protocols: - Reversibility - Propagation - Search Usually, Constraint Programming code consists of - the creation of the Solver, - the creation of the decision variables of the model, - the creation of the constraints of the model and their addition to the solver() through the AddConstraint() method, - the creation of the main DecisionBuilder class, - the launch of the solve() method with the decision builder. For the time being, Solver is neither MT_SAFE nor MT_HOT.
Select the first unbound variable. Variables are considered in the order of the vector of IntVars used to create the selector.
Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variables is the one with the lowest min value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.
Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variable is the one with the highest min value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.
Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variables is the one with the lowest max value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.
Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variable is the one with the highest max value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.
Among unbound variables, select the variable with the smallest minimal value. In case of a tie, the first one is selected, "first" defined by the order in the vector of IntVars used to create the selector.
Among unbound variables, select the variable with the highest maximal value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.
Among unbound variables, select the variable with the smallest size. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.
Among unbound variables, select the variable with the highest size. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.
Among unbound variables, select the variable with the largest gap between the first and the second values of the domain.
Selects the next unbound variable on a path, the path being defined by the variables: var[i] corresponds to the index of the next of i.
Selects the first possible value which is the closest to the center of the domain of the selected variable. The center is defined as (min + max) / 2.
Selects the variable with the lowest starting time of all variables, and fixes its starting time to this lowest value.
Selects the variable with the highest ending time of all variables, and fixes the ending time to this highest values.
Operator which reverses a sub-chain of a path. It is called TwoOpt because it breaks two arcs on the path; resulting paths are called two-optimal. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> [3 -> 2] -> 4 -> 5 1 -> [4 -> 3 -> 2] -> 5 1 -> 2 -> [4 -> 3] -> 5
Relocate: OROPT and RELOCATE. Operator which moves a sub-chain of a path to another position; the specified chain length is the fixed length of the chains being moved. When this length is 1, the operator simply moves a node to another position. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5, for a chain length of 2 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> 4 -> [2 -> 3] -> 5 1 -> [3 -> 4] -> 2 -> 5 Using Relocate with chain lengths of 1, 2 and 3 together is equivalent to the OrOpt operator on a path. The OrOpt operator is a limited version of 3Opt (breaks 3 arcs on a path).
Operator which exchanges the positions of two nodes. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> [3] -> [2] -> 4 -> 5 1 -> [4] -> 3 -> [2] -> 5 1 -> 2 -> [4] -> [3] -> 5
Operator which cross exchanges the starting chains of 2 paths, including exchanging the whole paths. First and last nodes are not moved. Possible neighbors for the paths 1 -> 2 -> 3 -> 4 -> 5 and 6 -> 7 -> 8 (where (1, 5) and (6, 8) are first and last nodes of the paths and can therefore not be moved): 1 -> [7] -> 3 -> 4 -> 5 6 -> [2] -> 8 1 -> [7] -> 4 -> 5 6 -> [2 -> 3] -> 8 1 -> [7] -> 5 6 -> [2 -> 3 -> 4] -> 8
Operator which inserts an inactive node into a path. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 2 -> 3 -> 4 1 -> 2 -> [5] -> 3 -> 4 1 -> 2 -> 3 -> [5] -> 4
Operator which makes path nodes inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are first and last nodes of the path) are: 1 -> 3 -> 4 with 2 inactive 1 -> 2 -> 4 with 3 inactive
Operator which makes a "chain" of path nodes inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are first and last nodes of the path) are: 1 -> 3 -> 4 with 2 inactive 1 -> 2 -> 4 with 3 inactive 1 -> 4 with 2 and 3 inactive
Operator which replaces an active node by an inactive one. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 3 -> 4 with 2 inactive 1 -> 2 -> [5] -> 4 with 3 inactive
Operator which makes an inactive node active and an active one inactive. It is similar to SwapActiveOperator except that it tries to insert the inactive node in all possible positions instead of just the position of the node made inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 3 -> 4 with 2 inactive 1 -> 3 -> [5] -> 4 with 2 inactive 1 -> [5] -> 2 -> 4 with 3 inactive 1 -> 2 -> [5] -> 4 with 3 inactive
Operator which relaxes two sub-chains of three consecutive arcs each. Each sub-chain is defined by a start node and the next three arcs. Those six arcs are relaxed to build a new neighbor. PATHLNS explores all possible pairs of starting nodes and so defines n^2 neighbors, n being the number of nodes. Note that the two sub-chains can be part of the same path; they even may overlap.
Operator which relaxes one entire path and all inactive nodes, thus defining num_paths neighbors.
Operator which relaxes all inactive nodes and one sub-chain of six consecutive arcs. That way the path can be improved by inserting inactive nodes or swapping arcs.
Operator which defines one neighbor per variable. Each neighbor tries to increment by one the value of the corresponding variable. When a new solution is found the neighborhood is rebuilt from scratch, i.e., tries to increment values in the variable order. Consider for instance variables x and y. x is incremented one by one to its max, and when it is not possible to increment x anymore, y is incremented once. If this is a solution, then next neighbor tries to increment x.
Operator which defines a neighborhood to decrement values. The behavior is the same as INCREMENT, except values are decremented instead of incremented.
Operator which defines one neighbor per variable. Each neighbor relaxes one variable. When a new solution is found the neighborhood is rebuilt from scratch. Consider for instance variables x and y. First x is relaxed and the solver is looking for the best possible solution (with only x relaxed). Then y is relaxed, and the solver is looking for a new solution. If a new solution is found, then the next variable to be relaxed is x.
Move is accepted when the current objective value is in the interval objective.Min .. objective.Max.
DELAYED_PRIORITY is the lowest priority: Demons will be processed after VAR_PRIORITY and NORMAL_PRIORITY demons.
213 def Parameters(self) -> "operations_research::ConstraintSolverParameters": 214 r""" Stored Parameters.""" 215 return _pywrapcp.Solver_Parameters(self)
Stored Parameters.
217 @staticmethod 218 def DefaultSolverParameters() -> "operations_research::ConstraintSolverParameters": 219 r""" Create a ConstraintSolverParameters proto with all the default values.""" 220 return _pywrapcp.Solver_DefaultSolverParameters()
Create a ConstraintSolverParameters proto with all the default values.
222 def AddConstraint(self, c: "Constraint") -> "void": 223 r""" Adds the constraint 'c' to the model. After calling this method, and until there is a backtrack that undoes the addition, any assignment of variables to values must satisfy the given constraint in order to be considered feasible. There are two fairly different use cases: - the most common use case is modeling: the given constraint is really part of the problem that the user is trying to solve. In this use case, AddConstraint is called outside of search (i.e., with state() == OUTSIDE_SEARCH). Most users should only use AddConstraint in this way. In this case, the constraint will belong to the model forever: it cannot not be removed by backtracking. - a rarer use case is that 'c' is not a real constraint of the model. It may be a constraint generated by a branching decision (a constraint whose goal is to restrict the search space), a symmetry breaking constraint (a constraint that does restrict the search space, but in a way that cannot have an impact on the quality of the solutions in the subtree), or an inferred constraint that, while having no semantic value to the model (it does not restrict the set of solutions), is worth having because we believe it may strengthen the propagation. In these cases, it happens that the constraint is added during the search (i.e., with state() == IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is added during a search, it applies only to the subtree of the search tree rooted at the current node, and will be automatically removed by backtracking. This method does not take ownership of the constraint. If the constraint has been created by any factory method (Solver::MakeXXX), it will automatically be deleted. However, power users who implement their own constraints should do: solver.AddConstraint(solver.RevAlloc(new MyConstraint(...));""" 224 return _pywrapcp.Solver_AddConstraint(self, c)
Adds the constraint 'c' to the model. After calling this method, and until there is a backtrack that undoes the addition, any assignment of variables to values must satisfy the given constraint in order to be considered feasible. There are two fairly different use cases: - the most common use case is modeling: the given constraint is really part of the problem that the user is trying to solve. In this use case, AddConstraint is called outside of search (i.e., with state() == OUTSIDE_SEARCH). Most users should only use AddConstraint in this way. In this case, the constraint will belong to the model forever: it cannot not be removed by backtracking. - a rarer use case is that 'c' is not a real constraint of the model. It may be a constraint generated by a branching decision (a constraint whose goal is to restrict the search space), a symmetry breaking constraint (a constraint that does restrict the search space, but in a way that cannot have an impact on the quality of the solutions in the subtree), or an inferred constraint that, while having no semantic value to the model (it does not restrict the set of solutions), is worth having because we believe it may strengthen the propagation. In these cases, it happens that the constraint is added during the search (i.e., with state() == IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is added during a search, it applies only to the subtree of the search tree rooted at the current node, and will be automatically removed by backtracking. This method does not take ownership of the constraint. If the constraint has been created by any factory method (Solver::MakeXXX), it will automatically be deleted. However, power users who implement their own constraints should do: solver.AddConstraint(solver.RevAlloc(new MyConstraint(...));
244 def CheckAssignment(self, solution: "Assignment") -> "bool": 245 r""" Checks whether the given assignment satisfies all relevant constraints.""" 246 return _pywrapcp.Solver_CheckAssignment(self, solution)
Checks whether the given assignment satisfies all relevant constraints.
248 def CheckConstraint(self, ct: "Constraint") -> "bool": 249 r""" Checks whether adding this constraint will lead to an immediate failure. It will return false if the model is already inconsistent, or if adding the constraint makes it inconsistent.""" 250 return _pywrapcp.Solver_CheckConstraint(self, ct)
Checks whether adding this constraint will lead to an immediate failure. It will return false if the model is already inconsistent, or if adding the constraint makes it inconsistent.
252 def Fail(self) -> "void": 253 r""" Abandon the current branch in the search tree. A backtrack will follow.""" 254 return _pywrapcp.Solver_Fail(self)
Abandon the current branch in the search tree. A backtrack will follow.
256 @staticmethod 257 def MemoryUsage() -> "int64_t": 258 r""" Current memory usage in bytes""" 259 return _pywrapcp.Solver_MemoryUsage()
Current memory usage in bytes
261 def WallTime(self) -> "int64_t": 262 r""" DEPRECATED: Use Now() instead. Time elapsed, in ms since the creation of the solver.""" 263 return _pywrapcp.Solver_WallTime(self)
DEPRECATED: Use Now() instead. Time elapsed, in ms since the creation of the solver.
265 def Branches(self) -> "int64_t": 266 r""" The number of branches explored since the creation of the solver.""" 267 return _pywrapcp.Solver_Branches(self)
The number of branches explored since the creation of the solver.
269 def Solutions(self) -> "int64_t": 270 r""" The number of solutions found since the start of the search.""" 271 return _pywrapcp.Solver_Solutions(self)
The number of solutions found since the start of the search.
273 def Failures(self) -> "int64_t": 274 r""" The number of failures encountered since the creation of the solver.""" 275 return _pywrapcp.Solver_Failures(self)
The number of failures encountered since the creation of the solver.
277 def AcceptedNeighbors(self) -> "int64_t": 278 r""" The number of accepted neighbors.""" 279 return _pywrapcp.Solver_AcceptedNeighbors(self)
The number of accepted neighbors.
281 def Stamp(self) -> "uint64_t": 282 r""" The stamp indicates how many moves in the search tree we have performed. It is useful to detect if we need to update same lazy structures.""" 283 return _pywrapcp.Solver_Stamp(self)
The stamp indicates how many moves in the search tree we have performed. It is useful to detect if we need to update same lazy structures.
285 def FailStamp(self) -> "uint64_t": 286 r""" The fail_stamp() is incremented after each backtrack.""" 287 return _pywrapcp.Solver_FailStamp(self)
The fail_stamp() is incremented after each backtrack.
289 def IntVar(self, *args) -> "operations_research::IntVar *": 290 r""" 291 *Overload 1:* 292 MakeIntVar will create the best range based int var for the bounds given. 293 294 | 295 296 *Overload 2:* 297 MakeIntVar will create a variable with the given sparse domain. 298 299 | 300 301 *Overload 3:* 302 MakeIntVar will create a variable with the given sparse domain. 303 304 | 305 306 *Overload 4:* 307 MakeIntVar will create the best range based int var for the bounds given. 308 309 | 310 311 *Overload 5:* 312 MakeIntVar will create a variable with the given sparse domain. 313 314 | 315 316 *Overload 6:* 317 MakeIntVar will create a variable with the given sparse domain. 318 """ 319 return _pywrapcp.Solver_IntVar(self, *args)
Overload 1: MakeIntVar will create the best range based int var for the bounds given.
|
Overload 2: MakeIntVar will create a variable with the given sparse domain.
|
Overload 3: MakeIntVar will create a variable with the given sparse domain.
|
Overload 4: MakeIntVar will create the best range based int var for the bounds given.
|
Overload 5: MakeIntVar will create a variable with the given sparse domain.
|
Overload 6: MakeIntVar will create a variable with the given sparse domain.
321 def BoolVar(self, *args) -> "operations_research::IntVar *": 322 r""" 323 *Overload 1:* 324 MakeBoolVar will create a variable with a {0, 1} domain. 325 326 | 327 328 *Overload 2:* 329 MakeBoolVar will create a variable with a {0, 1} domain. 330 """ 331 return _pywrapcp.Solver_BoolVar(self, *args)
Overload 1: MakeBoolVar will create a variable with a {0, 1} domain.
|
Overload 2: MakeBoolVar will create a variable with a {0, 1} domain.
333 def IntConst(self, *args) -> "operations_research::IntVar *": 334 r""" 335 *Overload 1:* 336 IntConst will create a constant expression. 337 338 | 339 340 *Overload 2:* 341 IntConst will create a constant expression. 342 """ 343 return _pywrapcp.Solver_IntConst(self, *args)
Overload 1: IntConst will create a constant expression.
|
Overload 2: IntConst will create a constant expression.
345 def Sum(self, vars: "std::vector< operations_research::IntVar * > const &") -> "operations_research::IntExpr *": 346 r""" sum of all vars.""" 347 return _pywrapcp.Solver_Sum(self, vars)
sum of all vars.
349 def ScalProd(self, *args) -> "operations_research::IntExpr *": 350 r""" 351 *Overload 1:* 352 scalar product 353 354 | 355 356 *Overload 2:* 357 scalar product 358 """ 359 return _pywrapcp.Solver_ScalProd(self, *args)
Overload 1: scalar product
|
Overload 2: scalar product
361 def MonotonicElement(self, values: "operations_research::Solver::IndexEvaluator1", increasing: "bool", index: "IntVar") -> "operations_research::IntExpr *": 362 r""" Function based element. The constraint takes ownership of the callback. The callback must be monotonic. It must be able to cope with any possible value in the domain of 'index' (potentially negative ones too). Furtermore, monotonicity is not checked. Thus giving a non-monotonic function, or specifying an incorrect increasing parameter will result in undefined behavior.""" 363 return _pywrapcp.Solver_MonotonicElement(self, values, increasing, index)
Function based element. The constraint takes ownership of the callback. The callback must be monotonic. It must be able to cope with any possible value in the domain of 'index' (potentially negative ones too). Furtermore, monotonicity is not checked. Thus giving a non-monotonic function, or specifying an incorrect increasing parameter will result in undefined behavior.
365 def Element(self, *args) -> "operations_research::IntExpr *": 366 r""" 367 *Overload 1:* 368 values[index] 369 370 | 371 372 *Overload 2:* 373 values[index] 374 375 | 376 377 *Overload 3:* 378 Function-based element. The constraint takes ownership of the callback. The callback must be able to cope with any possible value in the domain of 'index' (potentially negative ones too). 379 380 | 381 382 *Overload 4:* 383 2D version of function-based element expression, values(expr1, expr2). 384 385 | 386 387 *Overload 5:* 388 vars[expr] 389 """ 390 return _pywrapcp.Solver_Element(self, *args)
Overload 1: values[index]
|
Overload 2: values[index]
|
Overload 3: Function-based element. The constraint takes ownership of the callback. The callback must be able to cope with any possible value in the domain of 'index' (potentially negative ones too).
|
Overload 4: 2D version of function-based element expression, values(expr1, expr2).
|
Overload 5: vars[expr]
392 def IndexExpression(self, vars: "std::vector< operations_research::IntVar * > const &", value: "int64_t") -> "operations_research::IntExpr *": 393 r""" Returns the expression expr such that vars[expr] == value. It assumes that vars are all different.""" 394 return _pywrapcp.Solver_IndexExpression(self, vars, value)
Returns the expression expr such that vars[expr] == value. It assumes that vars are all different.
396 def Min(self, *args) -> "operations_research::IntExpr *": 397 r""" 398 *Overload 1:* 399 std::min(vars) 400 401 | 402 403 *Overload 2:* 404 std::min (left, right) 405 406 | 407 408 *Overload 3:* 409 std::min(expr, value) 410 411 | 412 413 *Overload 4:* 414 std::min(expr, value) 415 """ 416 return _pywrapcp.Solver_Min(self, *args)
Overload 1: std::min(vars)
|
Overload 2: std::min (left, right)
|
Overload 3: std::min(expr, value)
|
Overload 4: std::min(expr, value)
418 def Max(self, *args) -> "operations_research::IntExpr *": 419 r""" 420 *Overload 1:* 421 std::max(vars) 422 423 | 424 425 *Overload 2:* 426 std::max(left, right) 427 428 | 429 430 *Overload 3:* 431 std::max(expr, value) 432 433 | 434 435 *Overload 4:* 436 std::max(expr, value) 437 """ 438 return _pywrapcp.Solver_Max(self, *args)
Overload 1: std::max(vars)
|
Overload 2: std::max(left, right)
|
Overload 3: std::max(expr, value)
|
Overload 4: std::max(expr, value)
440 def ConvexPiecewiseExpr(self, expr: "IntExpr", early_cost: "int64_t", early_date: "int64_t", late_date: "int64_t", late_cost: "int64_t") -> "operations_research::IntExpr *": 441 r""" Convex piecewise function.""" 442 return _pywrapcp.Solver_ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost)
Convex piecewise function.
444 def SemiContinuousExpr(self, expr: "IntExpr", fixed_charge: "int64_t", step: "int64_t") -> "operations_research::IntExpr *": 445 r""" Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b) a >= 0 and b >= 0""" 446 return _pywrapcp.Solver_SemiContinuousExpr(self, expr, fixed_charge, step)
Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b) a >= 0 and b >= 0
448 def ConditionalExpression(self, condition: "IntVar", expr: "IntExpr", unperformed_value: "int64_t") -> "operations_research::IntExpr *": 449 r""" Conditional Expr condition ? expr : unperformed_value""" 450 return _pywrapcp.Solver_ConditionalExpression(self, condition, expr, unperformed_value)
Conditional Expr condition ? expr : unperformed_value
452 def TrueConstraint(self) -> "operations_research::Constraint *": 453 r""" This constraint always succeeds.""" 454 return _pywrapcp.Solver_TrueConstraint(self)
This constraint always succeeds.
459 def IsEqualCstCt(self, var: "IntExpr", value: "int64_t", boolvar: "IntVar") -> "operations_research::Constraint *": 460 r""" boolvar == (var == value)""" 461 return _pywrapcp.Solver_IsEqualCstCt(self, var, value, boolvar)
boolvar == (var == value)
463 def IsEqualCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 464 r""" status var of (var == value)""" 465 return _pywrapcp.Solver_IsEqualCstVar(self, var, value)
status var of (var == value)
467 def IsEqualCt(self, v1: "IntExpr", v2: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 468 r""" b == (v1 == v2)""" 469 return _pywrapcp.Solver_IsEqualCt(self, v1, v2, b)
b == (v1 == v2)
471 def IsEqualVar(self, v1: "IntExpr", v2: "IntExpr") -> "operations_research::IntVar *": 472 r""" status var of (v1 == v2)""" 473 return _pywrapcp.Solver_IsEqualVar(self, v1, v2)
status var of (v1 == v2)
475 def IsDifferentCstCt(self, var: "IntExpr", value: "int64_t", boolvar: "IntVar") -> "operations_research::Constraint *": 476 r""" boolvar == (var != value)""" 477 return _pywrapcp.Solver_IsDifferentCstCt(self, var, value, boolvar)
boolvar == (var != value)
479 def IsDifferentCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 480 r""" status var of (var != value)""" 481 return _pywrapcp.Solver_IsDifferentCstVar(self, var, value)
status var of (var != value)
483 def IsDifferentVar(self, v1: "IntExpr", v2: "IntExpr") -> "operations_research::IntVar *": 484 r""" status var of (v1 != v2)""" 485 return _pywrapcp.Solver_IsDifferentVar(self, v1, v2)
status var of (v1 != v2)
487 def IsDifferentCt(self, v1: "IntExpr", v2: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 488 r""" b == (v1 != v2)""" 489 return _pywrapcp.Solver_IsDifferentCt(self, v1, v2, b)
b == (v1 != v2)
491 def IsLessOrEqualCstCt(self, var: "IntExpr", value: "int64_t", boolvar: "IntVar") -> "operations_research::Constraint *": 492 r""" boolvar == (var <= value)""" 493 return _pywrapcp.Solver_IsLessOrEqualCstCt(self, var, value, boolvar)
boolvar == (var <= value)
495 def IsLessOrEqualCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 496 r""" status var of (var <= value)""" 497 return _pywrapcp.Solver_IsLessOrEqualCstVar(self, var, value)
status var of (var <= value)
499 def IsLessOrEqualVar(self, left: "IntExpr", right: "IntExpr") -> "operations_research::IntVar *": 500 r""" status var of (left <= right)""" 501 return _pywrapcp.Solver_IsLessOrEqualVar(self, left, right)
status var of (left <= right)
503 def IsLessOrEqualCt(self, left: "IntExpr", right: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 504 r""" b == (left <= right)""" 505 return _pywrapcp.Solver_IsLessOrEqualCt(self, left, right, b)
b == (left <= right)
507 def IsGreaterOrEqualCstCt(self, var: "IntExpr", value: "int64_t", boolvar: "IntVar") -> "operations_research::Constraint *": 508 r""" boolvar == (var >= value)""" 509 return _pywrapcp.Solver_IsGreaterOrEqualCstCt(self, var, value, boolvar)
boolvar == (var >= value)
511 def IsGreaterOrEqualCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 512 r""" status var of (var >= value)""" 513 return _pywrapcp.Solver_IsGreaterOrEqualCstVar(self, var, value)
status var of (var >= value)
515 def IsGreaterOrEqualVar(self, left: "IntExpr", right: "IntExpr") -> "operations_research::IntVar *": 516 r""" status var of (left >= right)""" 517 return _pywrapcp.Solver_IsGreaterOrEqualVar(self, left, right)
status var of (left >= right)
519 def IsGreaterOrEqualCt(self, left: "IntExpr", right: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 520 r""" b == (left >= right)""" 521 return _pywrapcp.Solver_IsGreaterOrEqualCt(self, left, right, b)
b == (left >= right)
523 def IsGreaterCstCt(self, v: "IntExpr", c: "int64_t", b: "IntVar") -> "operations_research::Constraint *": 524 r""" b == (v > c)""" 525 return _pywrapcp.Solver_IsGreaterCstCt(self, v, c, b)
b == (v > c)
527 def IsGreaterCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 528 r""" status var of (var > value)""" 529 return _pywrapcp.Solver_IsGreaterCstVar(self, var, value)
status var of (var > value)
531 def IsGreaterVar(self, left: "IntExpr", right: "IntExpr") -> "operations_research::IntVar *": 532 r""" status var of (left > right)""" 533 return _pywrapcp.Solver_IsGreaterVar(self, left, right)
status var of (left > right)
535 def IsGreaterCt(self, left: "IntExpr", right: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 536 r""" b == (left > right)""" 537 return _pywrapcp.Solver_IsGreaterCt(self, left, right, b)
b == (left > right)
539 def IsLessCstCt(self, v: "IntExpr", c: "int64_t", b: "IntVar") -> "operations_research::Constraint *": 540 r""" b == (v < c)""" 541 return _pywrapcp.Solver_IsLessCstCt(self, v, c, b)
b == (v < c)
543 def IsLessCstVar(self, var: "IntExpr", value: "int64_t") -> "operations_research::IntVar *": 544 r""" status var of (var < value)""" 545 return _pywrapcp.Solver_IsLessCstVar(self, var, value)
status var of (var < value)
547 def IsLessVar(self, left: "IntExpr", right: "IntExpr") -> "operations_research::IntVar *": 548 r""" status var of (left < right)""" 549 return _pywrapcp.Solver_IsLessVar(self, left, right)
status var of (left < right)
551 def IsLessCt(self, left: "IntExpr", right: "IntExpr", b: "IntVar") -> "operations_research::Constraint *": 552 r""" b == (left < right)""" 553 return _pywrapcp.Solver_IsLessCt(self, left, right, b)
b == (left < right)
555 def SumLessOrEqual(self, vars: "std::vector< operations_research::IntVar * > const &", cst: "int64_t") -> "operations_research::Constraint *": 556 r""" Variation on arrays.""" 557 return _pywrapcp.Solver_SumLessOrEqual(self, vars, cst)
Variation on arrays.
583 def AbsEquality(self, var: "IntVar", abs_var: "IntVar") -> "operations_research::Constraint *": 584 r""" Creates the constraint abs(var) == abs_var.""" 585 return _pywrapcp.Solver_AbsEquality(self, var, abs_var)
Creates the constraint abs(var) == abs_var.
587 def IndexOfConstraint(self, vars: "std::vector< operations_research::IntVar * > const &", index: "IntVar", target: "int64_t") -> "operations_research::Constraint *": 588 r""" This constraint is a special case of the element constraint with an array of integer variables, where the variables are all different and the index variable is constrained such that vars[index] == target.""" 589 return _pywrapcp.Solver_IndexOfConstraint(self, vars, index, target)
This constraint is a special case of the element constraint with an array of integer variables, where the variables are all different and the index variable is constrained such that vars[index] == target.
591 def ConstraintInitialPropagateCallback(self, ct: "Constraint") -> "operations_research::Demon *": 592 r""" This method is a specialized case of the MakeConstraintDemon method to call the InitiatePropagate of the constraint 'ct'.""" 593 return _pywrapcp.Solver_ConstraintInitialPropagateCallback(self, ct)
This method is a specialized case of the MakeConstraintDemon method to call the InitiatePropagate of the constraint 'ct'.
595 def DelayedConstraintInitialPropagateCallback(self, ct: "Constraint") -> "operations_research::Demon *": 596 r""" This method is a specialized case of the MakeConstraintDemon method to call the InitiatePropagate of the constraint 'ct' with low priority.""" 597 return _pywrapcp.Solver_DelayedConstraintInitialPropagateCallback(self, ct)
This method is a specialized case of the MakeConstraintDemon method to call the InitiatePropagate of the constraint 'ct' with low priority.
599 def ClosureDemon(self, closure: "operations_research::Solver::Closure") -> "operations_research::Demon *": 600 r""" Creates a demon from a closure.""" 601 return _pywrapcp.Solver_ClosureDemon(self, closure)
Creates a demon from a closure.
603 def BetweenCt(self, expr: "IntExpr", l: "int64_t", u: "int64_t") -> "operations_research::Constraint *": 604 r""" (l <= expr <= u)""" 605 return _pywrapcp.Solver_BetweenCt(self, expr, l, u)
(l <= expr <= u)
607 def IsBetweenCt(self, expr: "IntExpr", l: "int64_t", u: "int64_t", b: "IntVar") -> "operations_research::Constraint *": 608 r""" b == (l <= expr <= u)""" 609 return _pywrapcp.Solver_IsBetweenCt(self, expr, l, u, b)
b == (l <= expr <= u)
617 def NotMemberCt(self, *args) -> "operations_research::Constraint *": 618 r""" 619 *Overload 1:* 620 expr not in set. 621 622 | 623 624 *Overload 2:* 625 expr should not be in the list of forbidden intervals [start[i]..end[i]]. 626 627 | 628 629 *Overload 3:* 630 expr should not be in the list of forbidden intervals [start[i]..end[i]]. 631 """ 632 return _pywrapcp.Solver_NotMemberCt(self, *args)
Overload 1: expr not in set.
|
Overload 2: expr should not be in the list of forbidden intervals [start[i]..end[i]].
|
Overload 3: expr should not be in the list of forbidden intervals [start[i]..end[i]].
640 def Count(self, *args) -> "operations_research::Constraint *": 641 r""" 642 *Overload 1:* 643 |{i | vars[i] == value}| == max_count 644 645 | 646 647 *Overload 2:* 648 |{i | vars[i] == value}| == max_count 649 """ 650 return _pywrapcp.Solver_Count(self, *args)
Overload 1: |{i | vars[i] == value}| == max_count
|
Overload 2: |{i | vars[i] == value}| == max_count
652 def Distribute(self, *args) -> "operations_research::Constraint *": 653 r""" 654 *Overload 1:* 655 Aggregated version of count: |{i | v[i] == values[j]}| == cards[j] 656 657 | 658 659 *Overload 2:* 660 Aggregated version of count: |{i | v[i] == values[j]}| == cards[j] 661 662 | 663 664 *Overload 3:* 665 Aggregated version of count: |{i | v[i] == j}| == cards[j] 666 667 | 668 669 *Overload 4:* 670 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max 671 672 | 673 674 *Overload 5:* 675 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == j}| <= card_max[j] 676 677 | 678 679 *Overload 6:* 680 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == j}| <= card_max[j] 681 682 | 683 684 *Overload 7:* 685 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j] 686 687 | 688 689 *Overload 8:* 690 Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j] 691 """ 692 return _pywrapcp.Solver_Distribute(self, *args)
Overload 1: Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]
|
Overload 2: Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]
|
Overload 3: Aggregated version of count: |{i | v[i] == j}| == cards[j]
|
Overload 4: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max
|
Overload 5: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == j}| <= card_max[j]
|
Overload 6: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == j}| <= card_max[j]
|
Overload 7: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
|
Overload 8: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
694 def Deviation(self, vars: "std::vector< operations_research::IntVar * > const &", deviation_var: "IntVar", total_sum: "int64_t") -> "operations_research::Constraint *": 695 r""" Deviation constraint: sum_i |n * vars[i] - total_sum| <= deviation_var and sum_i vars[i] == total_sum n = #vars""" 696 return _pywrapcp.Solver_Deviation(self, vars, deviation_var, total_sum)
Deviation constraint: sum_i |n * vars[i] - total_sum| <= deviation_var and sum_i vars[i] == total_sum n = #vars
698 def AllDifferent(self, *args) -> "operations_research::Constraint *": 699 r""" 700 *Overload 1:* 701 All variables are pairwise different. This corresponds to the stronger version of the propagation algorithm. 702 703 | 704 705 *Overload 2:* 706 All variables are pairwise different. If 'stronger_propagation' is true, stronger, and potentially slower propagation will occur. This API will be deprecated in the future. 707 """ 708 return _pywrapcp.Solver_AllDifferent(self, *args)
Overload 1: All variables are pairwise different. This corresponds to the stronger version of the propagation algorithm.
|
Overload 2: All variables are pairwise different. If 'stronger_propagation' is true, stronger, and potentially slower propagation will occur. This API will be deprecated in the future.
710 def AllDifferentExcept(self, vars: "std::vector< operations_research::IntVar * > const &", escape_value: "int64_t") -> "operations_research::Constraint *": 711 r""" All variables are pairwise different, unless they are assigned to the escape value.""" 712 return _pywrapcp.Solver_AllDifferentExcept(self, vars, escape_value)
All variables are pairwise different, unless they are assigned to the escape value.
714 def SortingConstraint(self, vars: "std::vector< operations_research::IntVar * > const &", sorted: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 715 r""" Creates a constraint binding the arrays of variables "vars" and "sorted_vars": sorted_vars[0] must be equal to the minimum of all variables in vars, and so on: the value of sorted_vars[i] must be equal to the i-th value of variables invars. This constraint propagates in both directions: from "vars" to "sorted_vars" and vice-versa. Behind the scenes, this constraint maintains that: - sorted is always increasing. - whatever the values of vars, there exists a permutation that injects its values into the sorted variables. For more info, please have a look at: https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf""" 716 return _pywrapcp.Solver_SortingConstraint(self, vars, sorted)
Creates a constraint binding the arrays of variables "vars" and "sorted_vars": sorted_vars[0] must be equal to the minimum of all variables in vars, and so on: the value of sorted_vars[i] must be equal to the i-th value of variables invars. This constraint propagates in both directions: from "vars" to "sorted_vars" and vice-versa. Behind the scenes, this constraint maintains that: - sorted is always increasing. - whatever the values of vars, there exists a permutation that injects its values into the sorted variables. For more info, please have a look at: https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf
718 def LexicalLess(self, left: "std::vector< operations_research::IntVar * > const &", right: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 719 r""" Creates a constraint that enforces that left is lexicographically less than right.""" 720 return _pywrapcp.Solver_LexicalLess(self, left, right)
Creates a constraint that enforces that left is lexicographically less than right.
722 def LexicalLessOrEqual(self, left: "std::vector< operations_research::IntVar * > const &", right: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 723 r""" Creates a constraint that enforces that left is lexicographically less than or equal to right.""" 724 return _pywrapcp.Solver_LexicalLessOrEqual(self, left, right)
Creates a constraint that enforces that left is lexicographically less than or equal to right.
726 def InversePermutationConstraint(self, left: "std::vector< operations_research::IntVar * > const &", right: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 727 r""" Creates a constraint that enforces that 'left' and 'right' both represent permutations of [0..left.size()-1], and that 'right' is the inverse permutation of 'left', i.e. for all i in [0..left.size()-1], right[left[i]] = i.""" 728 return _pywrapcp.Solver_InversePermutationConstraint(self, left, right)
Creates a constraint that enforces that 'left' and 'right' both represent permutations of [0..left.size()-1], and that 'right' is the inverse permutation of 'left', i.e. for all i in [0..left.size()-1], right[left[i]] = i.
730 def NullIntersect(self, first_vars: "std::vector< operations_research::IntVar * > const &", second_vars: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 731 r""" Creates a constraint that states that all variables in the first vector are different from all variables in the second group. Thus the set of values in the first vector does not intersect with the set of values in the second vector.""" 732 return _pywrapcp.Solver_NullIntersect(self, first_vars, second_vars)
Creates a constraint that states that all variables in the first vector are different from all variables in the second group. Thus the set of values in the first vector does not intersect with the set of values in the second vector.
734 def NullIntersectExcept(self, first_vars: "std::vector< operations_research::IntVar * > const &", second_vars: "std::vector< operations_research::IntVar * > const &", escape_value: "int64_t") -> "operations_research::Constraint *": 735 r""" Creates a constraint that states that all variables in the first vector are different from all variables from the second group, unless they are assigned to the escape value. Thus the set of values in the first vector minus the escape value does not intersect with the set of values in the second vector.""" 736 return _pywrapcp.Solver_NullIntersectExcept(self, first_vars, second_vars, escape_value)
Creates a constraint that states that all variables in the first vector are different from all variables from the second group, unless they are assigned to the escape value. Thus the set of values in the first vector minus the escape value does not intersect with the set of values in the second vector.
738 def Circuit(self, nexts: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 739 r""" Force the "nexts" variable to create a complete Hamiltonian path.""" 740 return _pywrapcp.Solver_Circuit(self, nexts)
Force the "nexts" variable to create a complete Hamiltonian path.
742 def SubCircuit(self, nexts: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 743 r""" Force the "nexts" variable to create a complete Hamiltonian path for those that do not loop upon themselves.""" 744 return _pywrapcp.Solver_SubCircuit(self, nexts)
Force the "nexts" variable to create a complete Hamiltonian path for those that do not loop upon themselves.
746 def DelayedPathCumul(self, nexts: "std::vector< operations_research::IntVar * > const &", active: "std::vector< operations_research::IntVar * > const &", cumuls: "std::vector< operations_research::IntVar * > const &", transits: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 747 r""" Delayed version of the same constraint: propagation on the nexts variables is delayed until all constraints have propagated.""" 748 return _pywrapcp.Solver_DelayedPathCumul(self, nexts, active, cumuls, transits)
Delayed version of the same constraint: propagation on the nexts variables is delayed until all constraints have propagated.
750 def PathCumul(self, *args) -> "operations_research::Constraint *": 751 r""" 752 *Overload 1:* 753 Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transits[i]. Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. 754 755 | 756 757 *Overload 2:* 758 Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]). Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. Ownership of transit_evaluator is taken and it must be a repeatable callback. 759 760 | 761 762 *Overload 3:* 763 Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i]. Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. Ownership of transit_evaluator is taken and it must be a repeatable callback. 764 """ 765 return _pywrapcp.Solver_PathCumul(self, *args)
Overload 1: Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transits[i]. Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem.
|
Overload 2: Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]). Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. Ownership of transit_evaluator is taken and it must be a repeatable callback.
|
Overload 3: Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i]. Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. Ownership of transit_evaluator is taken and it must be a repeatable callback.
767 def AllowedAssignments(self, *args) -> "operations_research::Constraint *": 768 r""" 769 *Overload 1:* 770 This method creates a constraint where the graph of the relation between the variables is given in extension. There are 'arity' variables involved in the relation and the graph is given by a integer tuple set. 771 772 | 773 774 *Overload 2:* 775 Compatibility layer for Python API. 776 """ 777 return _pywrapcp.Solver_AllowedAssignments(self, *args)
Overload 1: This method creates a constraint where the graph of the relation between the variables is given in extension. There are 'arity' variables involved in the relation and the graph is given by a integer tuple set.
|
Overload 2: Compatibility layer for Python API.
785 def Pack(self, vars: "std::vector< operations_research::IntVar * > const &", number_of_bins: "int") -> "operations_research::Pack *": 786 r""" This constraint packs all variables onto 'number_of_bins' variables. For any given variable, a value of 'number_of_bins' indicates that the variable is not assigned to any bin. Dimensions, i.e., cumulative constraints on this packing, can be added directly from the pack class.""" 787 return _pywrapcp.Solver_Pack(self, vars, number_of_bins)
This constraint packs all variables onto 'number_of_bins' variables. For any given variable, a value of 'number_of_bins' indicates that the variable is not assigned to any bin. Dimensions, i.e., cumulative constraints on this packing, can be added directly from the pack class.
789 def FixedDurationIntervalVar(self, *args) -> "operations_research::IntervalVar *": 790 r""" 791 *Overload 1:* 792 Creates an interval var with a fixed duration. The duration must be greater than 0. If optional is true, then the interval can be performed or unperformed. If optional is false, then the interval is always performed. 793 794 | 795 796 *Overload 2:* 797 Creates a performed interval var with a fixed duration. The duration must be greater than 0. 798 799 | 800 801 *Overload 3:* 802 Creates an interval var with a fixed duration, and performed_variable. The duration must be greater than 0. 803 """ 804 return _pywrapcp.Solver_FixedDurationIntervalVar(self, *args)
Overload 1: Creates an interval var with a fixed duration. The duration must be greater than 0. If optional is true, then the interval can be performed or unperformed. If optional is false, then the interval is always performed.
|
Overload 2: Creates a performed interval var with a fixed duration. The duration must be greater than 0.
|
Overload 3: Creates an interval var with a fixed duration, and performed_variable. The duration must be greater than 0.
806 def FixedInterval(self, start: "int64_t", duration: "int64_t", name: "std::string const &") -> "operations_research::IntervalVar *": 807 r""" Creates a fixed and performed interval.""" 808 return _pywrapcp.Solver_FixedInterval(self, start, duration, name)
Creates a fixed and performed interval.
810 def IntervalVar(self, start_min: "int64_t", start_max: "int64_t", duration_min: "int64_t", duration_max: "int64_t", end_min: "int64_t", end_max: "int64_t", optional: "bool", name: "std::string const &") -> "operations_research::IntervalVar *": 811 r""" Creates an interval var by specifying the bounds on start, duration, and end.""" 812 return _pywrapcp.Solver_IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name)
Creates an interval var by specifying the bounds on start, duration, and end.
814 def MirrorInterval(self, interval_var: "IntervalVar") -> "operations_research::IntervalVar *": 815 r""" Creates an interval var that is the mirror image of the given one, that is, the interval var obtained by reversing the axis.""" 816 return _pywrapcp.Solver_MirrorInterval(self, interval_var)
Creates an interval var that is the mirror image of the given one, that is, the interval var obtained by reversing the axis.
818 def FixedDurationStartSyncedOnStartIntervalVar(self, interval_var: "IntervalVar", duration: "int64_t", offset: "int64_t") -> "operations_research::IntervalVar *": 819 r""" Creates an interval var with a fixed duration whose start is synchronized with the start of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.""" 820 return _pywrapcp.Solver_FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset)
Creates an interval var with a fixed duration whose start is synchronized with the start of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.
822 def FixedDurationStartSyncedOnEndIntervalVar(self, interval_var: "IntervalVar", duration: "int64_t", offset: "int64_t") -> "operations_research::IntervalVar *": 823 r""" Creates an interval var with a fixed duration whose start is synchronized with the end of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.""" 824 return _pywrapcp.Solver_FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset)
Creates an interval var with a fixed duration whose start is synchronized with the end of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.
826 def FixedDurationEndSyncedOnStartIntervalVar(self, interval_var: "IntervalVar", duration: "int64_t", offset: "int64_t") -> "operations_research::IntervalVar *": 827 r""" Creates an interval var with a fixed duration whose end is synchronized with the start of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.""" 828 return _pywrapcp.Solver_FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset)
Creates an interval var with a fixed duration whose end is synchronized with the start of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.
830 def FixedDurationEndSyncedOnEndIntervalVar(self, interval_var: "IntervalVar", duration: "int64_t", offset: "int64_t") -> "operations_research::IntervalVar *": 831 r""" Creates an interval var with a fixed duration whose end is synchronized with the end of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.""" 832 return _pywrapcp.Solver_FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset)
Creates an interval var with a fixed duration whose end is synchronized with the end of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.
834 def IntervalRelaxedMin(self, interval_var: "IntervalVar") -> "operations_research::IntervalVar *": 835 r""" Creates and returns an interval variable that wraps around the given one, relaxing the min start and end. Relaxing means making unbounded when optional. If the variable is non-optional, this method returns interval_var. More precisely, such an interval variable behaves as follows: * When the underlying must be performed, the returned interval variable behaves exactly as the underlying; * When the underlying may or may not be performed, the returned interval variable behaves like the underlying, except that it is unbounded on the min side; * When the underlying cannot be performed, the returned interval variable is of duration 0 and must be performed in an interval unbounded on both sides. This is very useful to implement propagators that may only modify the start max or end max.""" 836 return _pywrapcp.Solver_IntervalRelaxedMin(self, interval_var)
Creates and returns an interval variable that wraps around the given one, relaxing the min start and end. Relaxing means making unbounded when optional. If the variable is non-optional, this method returns interval_var. More precisely, such an interval variable behaves as follows: * When the underlying must be performed, the returned interval variable behaves exactly as the underlying; * When the underlying may or may not be performed, the returned interval variable behaves like the underlying, except that it is unbounded on the min side; * When the underlying cannot be performed, the returned interval variable is of duration 0 and must be performed in an interval unbounded on both sides. This is very useful to implement propagators that may only modify the start max or end max.
838 def IntervalRelaxedMax(self, interval_var: "IntervalVar") -> "operations_research::IntervalVar *": 839 r""" Creates and returns an interval variable that wraps around the given one, relaxing the max start and end. Relaxing means making unbounded when optional. If the variable is non optional, this method returns interval_var. More precisely, such an interval variable behaves as follows: * When the underlying must be performed, the returned interval variable behaves exactly as the underlying; * When the underlying may or may not be performed, the returned interval variable behaves like the underlying, except that it is unbounded on the max side; * When the underlying cannot be performed, the returned interval variable is of duration 0 and must be performed in an interval unbounded on both sides. This is very useful for implementing propagators that may only modify the start min or end min.""" 840 return _pywrapcp.Solver_IntervalRelaxedMax(self, interval_var)
Creates and returns an interval variable that wraps around the given one, relaxing the max start and end. Relaxing means making unbounded when optional. If the variable is non optional, this method returns interval_var. More precisely, such an interval variable behaves as follows: * When the underlying must be performed, the returned interval variable behaves exactly as the underlying; * When the underlying may or may not be performed, the returned interval variable behaves like the underlying, except that it is unbounded on the max side; * When the underlying cannot be performed, the returned interval variable is of duration 0 and must be performed in an interval unbounded on both sides. This is very useful for implementing propagators that may only modify the start min or end min.
842 def TemporalDisjunction(self, *args) -> "operations_research::Constraint *": 843 r""" 844 *Overload 1:* 845 This constraint implements a temporal disjunction between two interval vars t1 and t2. 'alt' indicates which alternative was chosen (alt == 0 is equivalent to t1 before t2). 846 847 | 848 849 *Overload 2:* 850 This constraint implements a temporal disjunction between two interval vars. 851 """ 852 return _pywrapcp.Solver_TemporalDisjunction(self, *args)
Overload 1: This constraint implements a temporal disjunction between two interval vars t1 and t2. 'alt' indicates which alternative was chosen (alt == 0 is equivalent to t1 before t2).
|
Overload 2: This constraint implements a temporal disjunction between two interval vars.
854 def DisjunctiveConstraint(self, intervals: "std::vector< operations_research::IntervalVar * > const &", name: "std::string const &") -> "operations_research::DisjunctiveConstraint *": 855 r""" This constraint forces all interval vars into an non-overlapping sequence. Intervals with zero duration can be scheduled anywhere.""" 856 return _pywrapcp.Solver_DisjunctiveConstraint(self, intervals, name)
This constraint forces all interval vars into an non-overlapping sequence. Intervals with zero duration can be scheduled anywhere.
858 def Cumulative(self, *args) -> "operations_research::Constraint *": 859 r""" 860 *Overload 1:* 861 This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint. 862 863 | 864 865 *Overload 2:* 866 This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint. 867 868 | 869 870 *Overload 3:* 871 This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint. 872 873 | 874 875 *Overload 4:* 876 This constraint enforces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint. 877 878 | 879 880 *Overload 5:* 881 This constraint enforces that, for any integer t, the sum of demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should be positive. 882 883 | 884 885 *Overload 6:* 886 This constraint enforces that, for any integer t, the sum of demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should be positive. 887 """ 888 return _pywrapcp.Solver_Cumulative(self, *args)
Overload 1: This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint.
|
Overload 2: This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint.
|
Overload 3: This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint.
|
Overload 4: This constraint enforces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint.
|
Overload 5: This constraint enforces that, for any integer t, the sum of demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should be positive.
|
Overload 6: This constraint enforces that, for any integer t, the sum of demands corresponding to an interval containing t does not exceed the given capacity. Intervals and demands should be vectors of equal size. Demands should be positive.
890 def Cover(self, vars: "std::vector< operations_research::IntervalVar * > const &", target_var: "IntervalVar") -> "operations_research::Constraint *": 891 r""" This constraint states that the target_var is the convex hull of the intervals. If none of the interval variables is performed, then the target var is unperformed too. Also, if the target variable is unperformed, then all the intervals variables are unperformed too.""" 892 return _pywrapcp.Solver_Cover(self, vars, target_var)
This constraint states that the target_var is the convex hull of the intervals. If none of the interval variables is performed, then the target var is unperformed too. Also, if the target variable is unperformed, then all the intervals variables are unperformed too.
894 def Assignment(self, *args) -> "operations_research::Assignment *": 895 r""" 896 *Overload 1:* 897 This method creates an empty assignment. 898 899 | 900 901 *Overload 2:* 902 This method creates an assignment which is a copy of 'a'. 903 """ 904 return _pywrapcp.Solver_Assignment(self, *args)
Overload 1: This method creates an empty assignment.
|
Overload 2: This method creates an assignment which is a copy of 'a'.
906 def FirstSolutionCollector(self, *args) -> "operations_research::SolutionCollector *": 907 r""" 908 *Overload 1:* 909 Collect the first solution of the search. 910 911 | 912 913 *Overload 2:* 914 Collect the first solution of the search. The variables will need to be added later. 915 """ 916 return _pywrapcp.Solver_FirstSolutionCollector(self, *args)
Overload 1: Collect the first solution of the search.
|
Overload 2: Collect the first solution of the search. The variables will need to be added later.
918 def LastSolutionCollector(self, *args) -> "operations_research::SolutionCollector *": 919 r""" 920 *Overload 1:* 921 Collect the last solution of the search. 922 923 | 924 925 *Overload 2:* 926 Collect the last solution of the search. The variables will need to be added later. 927 """ 928 return _pywrapcp.Solver_LastSolutionCollector(self, *args)
Overload 1: Collect the last solution of the search.
|
Overload 2: Collect the last solution of the search. The variables will need to be added later.
930 def BestValueSolutionCollector(self, *args) -> "operations_research::SolutionCollector *": 931 r""" 932 *Overload 1:* 933 Collect the solution corresponding to the optimal value of the objective of 'assignment'; if 'assignment' does not have an objective no solution is collected. This collector only collects one solution corresponding to the best objective value (the first one found). 934 935 | 936 937 *Overload 2:* 938 Collect the solution corresponding to the optimal value of the objective of 'assignment'; if 'assignment' does not have an objective no solution is collected. This collector only collects one solution corresponding to the best objective value (the first one found). The variables will need to be added later. 939 """ 940 return _pywrapcp.Solver_BestValueSolutionCollector(self, *args)
Overload 1: Collect the solution corresponding to the optimal value of the objective of 'assignment'; if 'assignment' does not have an objective no solution is collected. This collector only collects one solution corresponding to the best objective value (the first one found).
|
Overload 2: Collect the solution corresponding to the optimal value of the objective of 'assignment'; if 'assignment' does not have an objective no solution is collected. This collector only collects one solution corresponding to the best objective value (the first one found). The variables will need to be added later.
942 def AllSolutionCollector(self, *args) -> "operations_research::SolutionCollector *": 943 r""" 944 *Overload 1:* 945 Collect all solutions of the search. 946 947 | 948 949 *Overload 2:* 950 Collect all solutions of the search. The variables will need to be added later. 951 """ 952 return _pywrapcp.Solver_AllSolutionCollector(self, *args)
Overload 1: Collect all solutions of the search.
|
Overload 2: Collect all solutions of the search. The variables will need to be added later.
954 def Minimize(self, v: "IntVar", step: "int64_t") -> "operations_research::OptimizeVar *": 955 r""" Creates a minimization objective.""" 956 return _pywrapcp.Solver_Minimize(self, v, step)
Creates a minimization objective.
958 def Maximize(self, v: "IntVar", step: "int64_t") -> "operations_research::OptimizeVar *": 959 r""" Creates a maximization objective.""" 960 return _pywrapcp.Solver_Maximize(self, v, step)
Creates a maximization objective.
962 def Optimize(self, maximize: "bool", v: "IntVar", step: "int64_t") -> "operations_research::OptimizeVar *": 963 r""" Creates a objective with a given sense (true = maximization).""" 964 return _pywrapcp.Solver_Optimize(self, maximize, v, step)
Creates a objective with a given sense (true = maximization).
966 def WeightedMinimize(self, *args) -> "operations_research::OptimizeVar *": 967 r""" 968 *Overload 1:* 969 Creates a minimization weighted objective. The actual objective is scalar_prod(sub_objectives, weights). 970 971 | 972 973 *Overload 2:* 974 Creates a minimization weighted objective. The actual objective is scalar_prod(sub_objectives, weights). 975 """ 976 return _pywrapcp.Solver_WeightedMinimize(self, *args)
Overload 1: Creates a minimization weighted objective. The actual objective is scalar_prod(sub_objectives, weights).
|
Overload 2: Creates a minimization weighted objective. The actual objective is scalar_prod(sub_objectives, weights).
978 def WeightedMaximize(self, *args) -> "operations_research::OptimizeVar *": 979 r""" 980 *Overload 1:* 981 Creates a maximization weigthed objective. 982 983 | 984 985 *Overload 2:* 986 Creates a maximization weigthed objective. 987 """ 988 return _pywrapcp.Solver_WeightedMaximize(self, *args)
Overload 1: Creates a maximization weigthed objective.
|
Overload 2: Creates a maximization weigthed objective.
990 def WeightedOptimize(self, *args) -> "operations_research::OptimizeVar *": 991 r""" 992 *Overload 1:* 993 Creates a weighted objective with a given sense (true = maximization). 994 995 | 996 997 *Overload 2:* 998 Creates a weighted objective with a given sense (true = maximization). 999 """ 1000 return _pywrapcp.Solver_WeightedOptimize(self, *args)
Overload 1: Creates a weighted objective with a given sense (true = maximization).
|
Overload 2: Creates a weighted objective with a given sense (true = maximization).
1002 def TabuSearch(self, maximize: "bool", v: "IntVar", step: "int64_t", vars: "std::vector< operations_research::IntVar * > const &", keep_tenure: "int64_t", forbid_tenure: "int64_t", tabu_factor: "double") -> "operations_research::SearchMonitor *": 1003 r""" MetaHeuristics which try to get the search out of local optima. Creates a Tabu Search monitor. In the context of local search the behavior is similar to MakeOptimize(), creating an objective in a given sense. The behavior differs once a local optimum is reached: thereafter solutions which degrade the value of the objective are allowed if they are not "tabu". A solution is "tabu" if it doesn't respect the following rules: - improving the best solution found so far - variables in the "keep" list must keep their value, variables in the "forbid" list must not take the value they have in the list. Variables with new values enter the tabu lists after each new solution found and leave the lists after a given number of iterations (called tenure). Only the variables passed to the method can enter the lists. The tabu criterion is softened by the tabu factor which gives the number of "tabu" violations which is tolerated; a factor of 1 means no violations allowed; a factor of 0 means all violations are allowed.""" 1004 return _pywrapcp.Solver_TabuSearch(self, maximize, v, step, vars, keep_tenure, forbid_tenure, tabu_factor)
MetaHeuristics which try to get the search out of local optima. Creates a Tabu Search monitor. In the context of local search the behavior is similar to MakeOptimize(), creating an objective in a given sense. The behavior differs once a local optimum is reached: thereafter solutions which degrade the value of the objective are allowed if they are not "tabu". A solution is "tabu" if it doesn't respect the following rules: - improving the best solution found so far - variables in the "keep" list must keep their value, variables in the "forbid" list must not take the value they have in the list. Variables with new values enter the tabu lists after each new solution found and leave the lists after a given number of iterations (called tenure). Only the variables passed to the method can enter the lists. The tabu criterion is softened by the tabu factor which gives the number of "tabu" violations which is tolerated; a factor of 1 means no violations allowed; a factor of 0 means all violations are allowed.
1006 def SimulatedAnnealing(self, maximize: "bool", v: "IntVar", step: "int64_t", initial_temperature: "int64_t") -> "operations_research::SearchMonitor *": 1007 r""" Creates a Simulated Annealing monitor.""" 1008 return _pywrapcp.Solver_SimulatedAnnealing(self, maximize, v, step, initial_temperature)
Creates a Simulated Annealing monitor.
1010 def LubyRestart(self, scale_factor: "int") -> "operations_research::SearchMonitor *": 1011 r""" This search monitor will restart the search periodically. At the iteration n, it will restart after scale_factor * Luby(n) failures where Luby is the Luby Strategy (i.e. 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8...).""" 1012 return _pywrapcp.Solver_LubyRestart(self, scale_factor)
This search monitor will restart the search periodically. At the iteration n, it will restart after scale_factor * Luby(n) failures where Luby is the Luby Strategy (i.e. 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8...).
1014 def ConstantRestart(self, frequency: "int") -> "operations_research::SearchMonitor *": 1015 r""" This search monitor will restart the search periodically after 'frequency' failures.""" 1016 return _pywrapcp.Solver_ConstantRestart(self, frequency)
This search monitor will restart the search periodically after 'frequency' failures.
1021 def BranchesLimit(self, branches: "int64_t") -> "operations_research::RegularLimit *": 1022 r""" Creates a search limit that constrains the number of branches explored in the search tree.""" 1023 return _pywrapcp.Solver_BranchesLimit(self, branches)
Creates a search limit that constrains the number of branches explored in the search tree.
1025 def FailuresLimit(self, failures: "int64_t") -> "operations_research::RegularLimit *": 1026 r""" Creates a search limit that constrains the number of failures that can happen when exploring the search tree.""" 1027 return _pywrapcp.Solver_FailuresLimit(self, failures)
Creates a search limit that constrains the number of failures that can happen when exploring the search tree.
1029 def SolutionsLimit(self, solutions: "int64_t") -> "operations_research::RegularLimit *": 1030 r""" Creates a search limit that constrains the number of solutions found during the search.""" 1031 return _pywrapcp.Solver_SolutionsLimit(self, solutions)
Creates a search limit that constrains the number of solutions found during the search.
1033 def Limit(self, *args) -> "operations_research::SearchLimit *": 1034 r""" 1035 *Overload 1:* 1036 Limits the search with the 'time', 'branches', 'failures' and 'solutions' limits. 'smart_time_check' reduces the calls to the wall 1037 1038 | 1039 1040 *Overload 2:* 1041 Creates a search limit from its protobuf description 1042 1043 | 1044 1045 *Overload 3:* 1046 Creates a search limit that is reached when either of the underlying limit is reached. That is, the returned limit is more stringent than both argument limits. 1047 """ 1048 return _pywrapcp.Solver_Limit(self, *args)
Overload 1: Limits the search with the 'time', 'branches', 'failures' and 'solutions' limits. 'smart_time_check' reduces the calls to the wall
|
Overload 2: Creates a search limit from its protobuf description
|
Overload 3: Creates a search limit that is reached when either of the underlying limit is reached. That is, the returned limit is more stringent than both argument limits.
1050 def CustomLimit(self, limiter: "std::function< bool () >") -> "operations_research::SearchLimit *": 1051 r""" Callback-based search limit. Search stops when limiter returns true; if this happens at a leaf the corresponding solution will be rejected.""" 1052 return _pywrapcp.Solver_CustomLimit(self, limiter)
Callback-based search limit. Search stops when limiter returns true; if this happens at a leaf the corresponding solution will be rejected.
1057 def SearchTrace(self, prefix: "std::string const &") -> "operations_research::SearchMonitor *": 1058 r""" Creates a search monitor that will trace precisely the behavior of the search. Use this only for low level debugging.""" 1059 return _pywrapcp.Solver_SearchTrace(self, prefix)
Creates a search monitor that will trace precisely the behavior of the search. Use this only for low level debugging.
1061 def PrintModelVisitor(self) -> "operations_research::ModelVisitor *": 1062 r""" Prints the model.""" 1063 return _pywrapcp.Solver_PrintModelVisitor(self)
Prints the model.
1065 def StatisticsModelVisitor(self) -> "operations_research::ModelVisitor *": 1066 r""" Displays some nice statistics on the model.""" 1067 return _pywrapcp.Solver_StatisticsModelVisitor(self)
Displays some nice statistics on the model.
1069 def AssignVariableValue(self, var: "IntVar", val: "int64_t") -> "operations_research::Decision *": 1070 r""" Decisions.""" 1071 return _pywrapcp.Solver_AssignVariableValue(self, var, val)
Decisions.
1103 def ScheduleOrPostpone(self, var: "IntervalVar", est: "int64_t", marker: "int64_t *const") -> "operations_research::Decision *": 1104 r""" Returns a decision that tries to schedule a task at a given time. On the Apply branch, it will set that interval var as performed and set its start to 'est'. On the Refute branch, it will just update the 'marker' to 'est' + 1. This decision is used in the INTERVAL_SET_TIMES_FORWARD strategy.""" 1105 return _pywrapcp.Solver_ScheduleOrPostpone(self, var, est, marker)
Returns a decision that tries to schedule a task at a given time. On the Apply branch, it will set that interval var as performed and set its start to 'est'. On the Refute branch, it will just update the 'marker' to 'est' + 1. This decision is used in the INTERVAL_SET_TIMES_FORWARD strategy.
1107 def ScheduleOrExpedite(self, var: "IntervalVar", est: "int64_t", marker: "int64_t *const") -> "operations_research::Decision *": 1108 r""" Returns a decision that tries to schedule a task at a given time. On the Apply branch, it will set that interval var as performed and set its end to 'est'. On the Refute branch, it will just update the 'marker' to 'est' - 1. This decision is used in the INTERVAL_SET_TIMES_BACKWARD strategy.""" 1109 return _pywrapcp.Solver_ScheduleOrExpedite(self, var, est, marker)
Returns a decision that tries to schedule a task at a given time. On the Apply branch, it will set that interval var as performed and set its end to 'est'. On the Refute branch, it will just update the 'marker' to 'est' - 1. This decision is used in the INTERVAL_SET_TIMES_BACKWARD strategy.
1111 def RankFirstInterval(self, sequence: "SequenceVar", index: "int") -> "operations_research::Decision *": 1112 r""" Returns a decision that tries to rank first the ith interval var in the sequence variable.""" 1113 return _pywrapcp.Solver_RankFirstInterval(self, sequence, index)
Returns a decision that tries to rank first the ith interval var in the sequence variable.
1115 def RankLastInterval(self, sequence: "SequenceVar", index: "int") -> "operations_research::Decision *": 1116 r""" Returns a decision that tries to rank last the ith interval var in the sequence variable.""" 1117 return _pywrapcp.Solver_RankLastInterval(self, sequence, index)
Returns a decision that tries to rank last the ith interval var in the sequence variable.
1122 def DecisionBuilderFromAssignment(self, assignment: "Assignment", db: "DecisionBuilder", vars: "std::vector< operations_research::IntVar * > const &") -> "operations_research::DecisionBuilder *": 1123 r""" Returns a decision builder for which the left-most leaf corresponds to assignment, the rest of the tree being explored using 'db'.""" 1124 return _pywrapcp.Solver_DecisionBuilderFromAssignment(self, assignment, db, vars)
Returns a decision builder for which the left-most leaf corresponds to assignment, the rest of the tree being explored using 'db'.
1126 def ConstraintAdder(self, ct: "Constraint") -> "operations_research::DecisionBuilder *": 1127 r""" Returns a decision builder that will add the given constraint to the model.""" 1128 return _pywrapcp.Solver_ConstraintAdder(self, ct)
Returns a decision builder that will add the given constraint to the model.
1136 def RestoreAssignment(self, assignment: "Assignment") -> "operations_research::DecisionBuilder *": 1137 r""" Returns a DecisionBuilder which restores an Assignment (calls void Assignment::Restore())""" 1138 return _pywrapcp.Solver_RestoreAssignment(self, assignment)
Returns a DecisionBuilder which restores an Assignment (calls void Assignment::Restore())
1140 def StoreAssignment(self, assignment: "Assignment") -> "operations_research::DecisionBuilder *": 1141 r""" Returns a DecisionBuilder which stores an Assignment (calls void Assignment::Store())""" 1142 return _pywrapcp.Solver_StoreAssignment(self, assignment)
Returns a DecisionBuilder which stores an Assignment (calls void Assignment::Store())
1150 def MoveTowardTargetOperator(self, *args) -> "operations_research::LocalSearchOperator *": 1151 r""" 1152 *Overload 1:* 1153 Creates a local search operator that tries to move the assignment of some variables toward a target. The target is given as an Assignment. This operator generates neighbors in which the only difference compared to the current state is that one variable that belongs to the target assignment is set to its target value. 1154 1155 | 1156 1157 *Overload 2:* 1158 Creates a local search operator that tries to move the assignment of some variables toward a target. The target is given either as two vectors: a vector of variables and a vector of associated target values. The two vectors should be of the same length. This operator generates neighbors in which the only difference compared to the current state is that one variable that belongs to the given vector is set to its target value. 1159 """ 1160 return _pywrapcp.Solver_MoveTowardTargetOperator(self, *args)
Overload 1: Creates a local search operator that tries to move the assignment of some variables toward a target. The target is given as an Assignment. This operator generates neighbors in which the only difference compared to the current state is that one variable that belongs to the target assignment is set to its target value.
|
Overload 2: Creates a local search operator that tries to move the assignment of some variables toward a target. The target is given either as two vectors: a vector of variables and a vector of associated target values. The two vectors should be of the same length. This operator generates neighbors in which the only difference compared to the current state is that one variable that belongs to the given vector is set to its target value.
1165 def RandomConcatenateOperators(self, *args) -> "operations_research::LocalSearchOperator *": 1166 r""" 1167 *Overload 1:* 1168 Randomized version of local search concatenator; calls a random operator at each call to MakeNextNeighbor(). 1169 1170 | 1171 1172 *Overload 2:* 1173 Randomized version of local search concatenator; calls a random operator at each call to MakeNextNeighbor(). The provided seed is used to initialize the random number generator. 1174 """ 1175 return _pywrapcp.Solver_RandomConcatenateOperators(self, *args)
Overload 1: Randomized version of local search concatenator; calls a random operator at each call to MakeNextNeighbor().
|
Overload 2: Randomized version of local search concatenator; calls a random operator at each call to MakeNextNeighbor(). The provided seed is used to initialize the random number generator.
1177 def NeighborhoodLimit(self, op: "LocalSearchOperator", limit: "int64_t") -> "operations_research::LocalSearchOperator *": 1178 r""" Creates a local search operator that wraps another local search operator and limits the number of neighbors explored (i.e., calls to MakeNextNeighbor from the current solution (between two calls to Start()). When this limit is reached, MakeNextNeighbor() returns false. The counter is cleared when Start() is called.""" 1179 return _pywrapcp.Solver_NeighborhoodLimit(self, op, limit)
Creates a local search operator that wraps another local search operator and limits the number of neighbors explored (i.e., calls to MakeNextNeighbor from the current solution (between two calls to Start()). When this limit is reached, MakeNextNeighbor() returns false. The counter is cleared when Start() is called.
1187 def SearchDepth(self) -> "int": 1188 r""" Gets the search depth of the current active search. Returns -1 if there is no active search opened.""" 1189 return _pywrapcp.Solver_SearchDepth(self)
Gets the search depth of the current active search. Returns -1 if there is no active search opened.
1191 def SearchLeftDepth(self) -> "int": 1192 r""" Gets the search left depth of the current active search. Returns -1 if there is no active search opened.""" 1193 return _pywrapcp.Solver_SearchLeftDepth(self)
Gets the search left depth of the current active search. Returns -1 if there is no active search opened.
1195 def SolveDepth(self) -> "int": 1196 r""" Gets the number of nested searches. It returns 0 outside search, 1 during the top level search, 2 or more in case of nested searches.""" 1197 return _pywrapcp.Solver_SolveDepth(self)
Gets the number of nested searches. It returns 0 outside search, 1 during the top level search, 2 or more in case of nested searches.
1199 def Rand64(self, size: "int64_t") -> "int64_t": 1200 r""" Returns a random value between 0 and 'size' - 1;""" 1201 return _pywrapcp.Solver_Rand64(self, size)
Returns a random value between 0 and 'size' - 1;
1203 def Rand32(self, size: "int32_t") -> "int32_t": 1204 r""" Returns a random value between 0 and 'size' - 1;""" 1205 return _pywrapcp.Solver_Rand32(self, size)
Returns a random value between 0 and 'size' - 1;
1207 def ReSeed(self, seed: "int32_t") -> "void": 1208 r""" Reseed the solver random generator.""" 1209 return _pywrapcp.Solver_ReSeed(self, seed)
Reseed the solver random generator.
1211 def LocalSearchProfile(self) -> "std::string": 1212 r""" Returns local search profiling information in a human readable format.""" 1213 return _pywrapcp.Solver_LocalSearchProfile(self)
Returns local search profiling information in a human readable format.
1215 def Constraints(self) -> "int": 1216 r""" Counts the number of constraints that have been added to the solver before the search.""" 1217 return _pywrapcp.Solver_Constraints(self)
Counts the number of constraints that have been added to the solver before the search.
1219 def Accept(self, visitor: "operations_research::ModelVisitor *const") -> "void": 1220 r""" Accepts the given model visitor.""" 1221 return _pywrapcp.Solver_Accept(self, visitor)
Accepts the given model visitor.
1223 def FinishCurrentSearch(self) -> "void": 1224 r""" Tells the solver to kill or restart the current search.""" 1225 return _pywrapcp.Solver_FinishCurrentSearch(self)
Tells the solver to kill or restart the current search.
1230 def ShouldFail(self) -> "void": 1231 r""" These methods are only useful for the SWIG wrappers, which need a way to externally cause the Solver to fail.""" 1232 return _pywrapcp.Solver_ShouldFail(self)
These methods are only useful for the SWIG wrappers, which need a way to externally cause the Solver to fail.
1243 def TreeNoCycle(self, nexts: "std::vector< operations_research::IntVar * > const &", active: "std::vector< operations_research::IntVar * > const &", callback: "operations_research::Solver::IndexFilter1"=0) -> "operations_research::Constraint *": 1244 return _pywrapcp.Solver_TreeNoCycle(self, nexts, active, callback)
1252 def VarEvalValStrPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_evaluator: "std::function< int64_t (int64_t) >", val_str: "operations_research::Solver::IntValueStrategy") -> "operations_research::DecisionBuilder *": 1253 return _pywrapcp.Solver_VarEvalValStrPhase(self, vars, var_evaluator, val_str)
1255 def VarStrValEvalPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_str: "operations_research::Solver::IntVarStrategy", val_eval: "operations_research::Solver::IndexEvaluator2") -> "operations_research::DecisionBuilder *": 1256 return _pywrapcp.Solver_VarStrValEvalPhase(self, vars, var_str, val_eval)
1258 def VarEvalValEvalPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_eval: "std::function< int64_t (int64_t) >", val_eval: "operations_research::Solver::IndexEvaluator2") -> "operations_research::DecisionBuilder *": 1259 return _pywrapcp.Solver_VarEvalValEvalPhase(self, vars, var_eval, val_eval)
1261 def VarStrValEvalTieBreakPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_str: "operations_research::Solver::IntVarStrategy", val_eval: "operations_research::Solver::IndexEvaluator2", tie_breaker: "std::function< int64_t (int64_t) >") -> "operations_research::DecisionBuilder *": 1262 return _pywrapcp.Solver_VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker)
1264 def VarEvalValEvalTieBreakPhase(self, vars: "std::vector< operations_research::IntVar * > const &", var_eval: "std::function< int64_t (int64_t) >", val_eval: "operations_research::Solver::IndexEvaluator2", tie_breaker: "std::function< int64_t (int64_t) >") -> "operations_research::DecisionBuilder *": 1265 return _pywrapcp.Solver_VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker)
1267 def EvalEvalStrPhase(self, vars: "std::vector< operations_research::IntVar * > const &", evaluator: "operations_research::Solver::IndexEvaluator2", str: "operations_research::Solver::EvaluatorStrategy") -> "operations_research::DecisionBuilder *": 1268 return _pywrapcp.Solver_EvalEvalStrPhase(self, vars, evaluator, str)
1270 def EvalEvalStrTieBreakPhase(self, vars: "std::vector< operations_research::IntVar * > const &", evaluator: "operations_research::Solver::IndexEvaluator2", tie_breaker: "operations_research::Solver::IndexEvaluator1", str: "operations_research::Solver::EvaluatorStrategy") -> "operations_research::DecisionBuilder *": 1271 return _pywrapcp.Solver_EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str)
1276 def SumObjectiveFilter(self, vars: "std::vector< operations_research::IntVar * > const &", values: "operations_research::Solver::IndexEvaluator2", filter_enum: "operations_research::Solver::LocalSearchFilterBound") -> "operations_research::LocalSearchFilter *": 1277 return _pywrapcp.Solver_SumObjectiveFilter(self, vars, values, filter_enum)
1282def Solver_DefaultSolverParameters() -> "operations_research::ConstraintSolverParameters": 1283 r""" Create a ConstraintSolverParameters proto with all the default values.""" 1284 return _pywrapcp.Solver_DefaultSolverParameters()
Create a ConstraintSolverParameters proto with all the default values.
1286def Solver_MemoryUsage() -> "int64_t": 1287 r""" Current memory usage in bytes""" 1288 return _pywrapcp.Solver_MemoryUsage()
Current memory usage in bytes
1290class BaseObject(object): 1291 r""" A BaseObject is the root of all reversibly allocated objects. A DebugString method and the associated << operator are implemented as a convenience.""" 1292 1293 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1294 1295 def __init__(self): 1296 if self.__class__ == BaseObject: 1297 _self = None 1298 else: 1299 _self = self 1300 _pywrapcp.BaseObject_swiginit(self, _pywrapcp.new_BaseObject(_self, )) 1301 __swig_destroy__ = _pywrapcp.delete_BaseObject 1302 1303 def DebugString(self) -> "std::string": 1304 return _pywrapcp.BaseObject_DebugString(self) 1305 1306 def __str__(self) -> "std::string": 1307 return _pywrapcp.BaseObject___str__(self) 1308 1309 def __repr__(self) -> "std::string": 1310 return _pywrapcp.BaseObject___repr__(self) 1311 def __disown__(self): 1312 self.this.disown() 1313 _pywrapcp.disown_BaseObject(self) 1314 return weakref.proxy(self)
A BaseObject is the root of all reversibly allocated objects. A DebugString method and the associated << operator are implemented as a convenience.
1319class PropagationBaseObject(BaseObject): 1320 r""" NOLINT The PropagationBaseObject is a subclass of BaseObject that is also friend to the Solver class. It allows accessing methods useful when writing new constraints or new expressions.""" 1321 1322 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1323 __repr__ = _swig_repr 1324 1325 def __init__(self, s: "Solver"): 1326 if self.__class__ == PropagationBaseObject: 1327 _self = None 1328 else: 1329 _self = self 1330 _pywrapcp.PropagationBaseObject_swiginit(self, _pywrapcp.new_PropagationBaseObject(_self, s)) 1331 __swig_destroy__ = _pywrapcp.delete_PropagationBaseObject 1332 1333 def DebugString(self) -> "std::string": 1334 return _pywrapcp.PropagationBaseObject_DebugString(self) 1335 1336 def solver(self) -> "operations_research::Solver *": 1337 return _pywrapcp.PropagationBaseObject_solver(self) 1338 1339 def Name(self) -> "std::string": 1340 r""" Object naming.""" 1341 return _pywrapcp.PropagationBaseObject_Name(self) 1342 def __disown__(self): 1343 self.this.disown() 1344 _pywrapcp.disown_PropagationBaseObject(self) 1345 return weakref.proxy(self)
NOLINT The PropagationBaseObject is a subclass of BaseObject that is also friend to the Solver class. It allows accessing methods useful when writing new constraints or new expressions.
1350class Decision(BaseObject): 1351 r""" A Decision represents a choice point in the search tree. The two main methods are Apply() to go left, or Refute() to go right.""" 1352 1353 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1354 1355 def __init__(self): 1356 if self.__class__ == Decision: 1357 _self = None 1358 else: 1359 _self = self 1360 _pywrapcp.Decision_swiginit(self, _pywrapcp.new_Decision(_self, )) 1361 __swig_destroy__ = _pywrapcp.delete_Decision 1362 1363 def ApplyWrapper(self, s: "Solver") -> "void": 1364 r""" Apply will be called first when the decision is executed.""" 1365 return _pywrapcp.Decision_ApplyWrapper(self, s) 1366 1367 def RefuteWrapper(self, s: "Solver") -> "void": 1368 r""" Refute will be called after a backtrack.""" 1369 return _pywrapcp.Decision_RefuteWrapper(self, s) 1370 1371 def DebugString(self) -> "std::string": 1372 return _pywrapcp.Decision_DebugString(self) 1373 1374 def __repr__(self) -> "std::string": 1375 return _pywrapcp.Decision___repr__(self) 1376 1377 def __str__(self) -> "std::string": 1378 return _pywrapcp.Decision___str__(self) 1379 def __disown__(self): 1380 self.this.disown() 1381 _pywrapcp.disown_Decision(self) 1382 return weakref.proxy(self)
A Decision represents a choice point in the search tree. The two main methods are Apply() to go left, or Refute() to go right.
1363 def ApplyWrapper(self, s: "Solver") -> "void": 1364 r""" Apply will be called first when the decision is executed.""" 1365 return _pywrapcp.Decision_ApplyWrapper(self, s)
Apply will be called first when the decision is executed.
1387class DecisionBuilder(BaseObject): 1388 r""" A DecisionBuilder is responsible for creating the search tree. The important method is Next(), which returns the next decision to execute.""" 1389 1390 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1391 1392 def __init__(self): 1393 if self.__class__ == DecisionBuilder: 1394 _self = None 1395 else: 1396 _self = self 1397 _pywrapcp.DecisionBuilder_swiginit(self, _pywrapcp.new_DecisionBuilder(_self, )) 1398 __swig_destroy__ = _pywrapcp.delete_DecisionBuilder 1399 1400 def NextWrapper(self, s: "Solver") -> "operations_research::Decision *": 1401 r""" This is the main method of the decision builder class. It must return a decision (an instance of the class Decision). If it returns nullptr, this means that the decision builder has finished its work.""" 1402 return _pywrapcp.DecisionBuilder_NextWrapper(self, s) 1403 1404 def DebugString(self) -> "std::string": 1405 return _pywrapcp.DecisionBuilder_DebugString(self) 1406 1407 def __repr__(self) -> "std::string": 1408 return _pywrapcp.DecisionBuilder___repr__(self) 1409 1410 def __str__(self) -> "std::string": 1411 return _pywrapcp.DecisionBuilder___str__(self) 1412 def __disown__(self): 1413 self.this.disown() 1414 _pywrapcp.disown_DecisionBuilder(self) 1415 return weakref.proxy(self)
A DecisionBuilder is responsible for creating the search tree. The important method is Next(), which returns the next decision to execute.
1400 def NextWrapper(self, s: "Solver") -> "operations_research::Decision *": 1401 r""" This is the main method of the decision builder class. It must return a decision (an instance of the class Decision). If it returns nullptr, this means that the decision builder has finished its work.""" 1402 return _pywrapcp.DecisionBuilder_NextWrapper(self, s)
This is the main method of the decision builder class. It must return a decision (an instance of the class Decision). If it returns nullptr, this means that the decision builder has finished its work.
1420class Demon(BaseObject): 1421 r""" A Demon is the base element of a propagation queue. It is the main object responsible for implementing the actual propagation of the constraint and pruning the inconsistent values in the domains of the variables. The main concept is that demons are listeners that are attached to the variables and listen to their modifications. There are two methods: - Run() is the actual method called when the demon is processed. - priority() returns its priority. Standard priorities are slow, normal or fast. "immediate" is reserved for variables and is treated separately.""" 1422 1423 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1424 __repr__ = _swig_repr 1425 1426 def __init__(self): 1427 r""" This indicates the priority of a demon. Immediate demons are treated separately and corresponds to variables.""" 1428 if self.__class__ == Demon: 1429 _self = None 1430 else: 1431 _self = self 1432 _pywrapcp.Demon_swiginit(self, _pywrapcp.new_Demon(_self, )) 1433 __swig_destroy__ = _pywrapcp.delete_Demon 1434 1435 def RunWrapper(self, s: "Solver") -> "void": 1436 r""" This is the main callback of the demon.""" 1437 return _pywrapcp.Demon_RunWrapper(self, s) 1438 1439 def Priority(self) -> "operations_research::Solver::DemonPriority": 1440 r""" This method returns the priority of the demon. Usually a demon is fast, slow or normal. Immediate demons are reserved for internal use to maintain variables.""" 1441 return _pywrapcp.Demon_Priority(self) 1442 1443 def DebugString(self) -> "std::string": 1444 return _pywrapcp.Demon_DebugString(self) 1445 1446 def Inhibit(self, s: "Solver") -> "void": 1447 r""" This method inhibits the demon in the search tree below the current position.""" 1448 return _pywrapcp.Demon_Inhibit(self, s) 1449 1450 def Desinhibit(self, s: "Solver") -> "void": 1451 r""" This method un-inhibits the demon that was previously inhibited.""" 1452 return _pywrapcp.Demon_Desinhibit(self, s) 1453 def __disown__(self): 1454 self.this.disown() 1455 _pywrapcp.disown_Demon(self) 1456 return weakref.proxy(self)
A Demon is the base element of a propagation queue. It is the main object responsible for implementing the actual propagation of the constraint and pruning the inconsistent values in the domains of the variables. The main concept is that demons are listeners that are attached to the variables and listen to their modifications. There are two methods: - Run() is the actual method called when the demon is processed. - priority() returns its priority. Standard priorities are slow, normal or fast. "immediate" is reserved for variables and is treated separately.
1426 def __init__(self): 1427 r""" This indicates the priority of a demon. Immediate demons are treated separately and corresponds to variables.""" 1428 if self.__class__ == Demon: 1429 _self = None 1430 else: 1431 _self = self 1432 _pywrapcp.Demon_swiginit(self, _pywrapcp.new_Demon(_self, ))
This indicates the priority of a demon. Immediate demons are treated separately and corresponds to variables.
1435 def RunWrapper(self, s: "Solver") -> "void": 1436 r""" This is the main callback of the demon.""" 1437 return _pywrapcp.Demon_RunWrapper(self, s)
This is the main callback of the demon.
1439 def Priority(self) -> "operations_research::Solver::DemonPriority": 1440 r""" This method returns the priority of the demon. Usually a demon is fast, slow or normal. Immediate demons are reserved for internal use to maintain variables.""" 1441 return _pywrapcp.Demon_Priority(self)
This method returns the priority of the demon. Usually a demon is fast, slow or normal. Immediate demons are reserved for internal use to maintain variables.
1446 def Inhibit(self, s: "Solver") -> "void": 1447 r""" This method inhibits the demon in the search tree below the current position.""" 1448 return _pywrapcp.Demon_Inhibit(self, s)
This method inhibits the demon in the search tree below the current position.
1461class Constraint(PropagationBaseObject): 1462 r""" A constraint is the main modeling object. It provides two methods: - Post() is responsible for creating the demons and attaching them to immediate demons(). - InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.""" 1463 1464 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1465 1466 def __init__(self, solver: "Solver"): 1467 if self.__class__ == Constraint: 1468 _self = None 1469 else: 1470 _self = self 1471 _pywrapcp.Constraint_swiginit(self, _pywrapcp.new_Constraint(_self, solver)) 1472 __swig_destroy__ = _pywrapcp.delete_Constraint 1473 1474 def Post(self) -> "void": 1475 r""" This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.""" 1476 return _pywrapcp.Constraint_Post(self) 1477 1478 def InitialPropagateWrapper(self) -> "void": 1479 r""" This method performs the initial propagation of the constraint. It is called just after the post.""" 1480 return _pywrapcp.Constraint_InitialPropagateWrapper(self) 1481 1482 def DebugString(self) -> "std::string": 1483 return _pywrapcp.Constraint_DebugString(self) 1484 1485 def Var(self) -> "operations_research::IntVar *": 1486 r""" Creates a Boolean variable representing the status of the constraint (false = constraint is violated, true = constraint is satisfied). It returns nullptr if the constraint does not support this API.""" 1487 return _pywrapcp.Constraint_Var(self) 1488 1489 def __repr__(self) -> "std::string": 1490 return _pywrapcp.Constraint___repr__(self) 1491 1492 def __str__(self) -> "std::string": 1493 return _pywrapcp.Constraint___str__(self) 1494 1495 def __add__(self, *args) -> "operations_research::IntExpr *": 1496 return _pywrapcp.Constraint___add__(self, *args) 1497 1498 def __radd__(self, v: "int64_t") -> "operations_research::IntExpr *": 1499 return _pywrapcp.Constraint___radd__(self, v) 1500 1501 def __sub__(self, *args) -> "operations_research::IntExpr *": 1502 return _pywrapcp.Constraint___sub__(self, *args) 1503 1504 def __rsub__(self, v: "int64_t") -> "operations_research::IntExpr *": 1505 return _pywrapcp.Constraint___rsub__(self, v) 1506 1507 def __mul__(self, *args) -> "operations_research::IntExpr *": 1508 return _pywrapcp.Constraint___mul__(self, *args) 1509 1510 def __rmul__(self, v: "int64_t") -> "operations_research::IntExpr *": 1511 return _pywrapcp.Constraint___rmul__(self, v) 1512 1513 def __floordiv__(self, v: "int64_t") -> "operations_research::IntExpr *": 1514 return _pywrapcp.Constraint___floordiv__(self, v) 1515 1516 def __neg__(self) -> "operations_research::IntExpr *": 1517 return _pywrapcp.Constraint___neg__(self) 1518 1519 def __abs__(self) -> "operations_research::IntExpr *": 1520 return _pywrapcp.Constraint___abs__(self) 1521 1522 def Square(self) -> "operations_research::IntExpr *": 1523 return _pywrapcp.Constraint_Square(self) 1524 1525 def __eq__(self, *args) -> "operations_research::Constraint *": 1526 return _pywrapcp.Constraint___eq__(self, *args) 1527 1528 def __ne__(self, *args) -> "operations_research::Constraint *": 1529 return _pywrapcp.Constraint___ne__(self, *args) 1530 1531 def __ge__(self, *args) -> "operations_research::Constraint *": 1532 return _pywrapcp.Constraint___ge__(self, *args) 1533 1534 def __gt__(self, *args) -> "operations_research::Constraint *": 1535 return _pywrapcp.Constraint___gt__(self, *args) 1536 1537 def __le__(self, *args) -> "operations_research::Constraint *": 1538 return _pywrapcp.Constraint___le__(self, *args) 1539 1540 def __lt__(self, *args) -> "operations_research::Constraint *": 1541 return _pywrapcp.Constraint___lt__(self, *args) 1542 1543 def MapTo(self, vars: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 1544 return _pywrapcp.Constraint_MapTo(self, vars) 1545 1546 def IndexOf(self, *args) -> "operations_research::IntExpr *": 1547 return _pywrapcp.Constraint_IndexOf(self, *args) 1548 def __disown__(self): 1549 self.this.disown() 1550 _pywrapcp.disown_Constraint(self) 1551 return weakref.proxy(self)
A constraint is the main modeling object. It provides two methods: - Post() is responsible for creating the demons and attaching them to immediate demons(). - InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.
1474 def Post(self) -> "void": 1475 r""" This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.""" 1476 return _pywrapcp.Constraint_Post(self)
This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.
1478 def InitialPropagateWrapper(self) -> "void": 1479 r""" This method performs the initial propagation of the constraint. It is called just after the post.""" 1480 return _pywrapcp.Constraint_InitialPropagateWrapper(self)
This method performs the initial propagation of the constraint. It is called just after the post.
1485 def Var(self) -> "operations_research::IntVar *": 1486 r""" Creates a Boolean variable representing the status of the constraint (false = constraint is violated, true = constraint is satisfied). It returns nullptr if the constraint does not support this API.""" 1487 return _pywrapcp.Constraint_Var(self)
Creates a Boolean variable representing the status of the constraint (false = constraint is violated, true = constraint is satisfied). It returns nullptr if the constraint does not support this API.
Inherited Members
1556class SearchMonitor(BaseObject): 1557 r""" A search monitor is a simple set of callbacks to monitor all search events""" 1558 1559 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1560 1561 def __init__(self, s: "Solver"): 1562 if self.__class__ == SearchMonitor: 1563 _self = None 1564 else: 1565 _self = self 1566 _pywrapcp.SearchMonitor_swiginit(self, _pywrapcp.new_SearchMonitor(_self, s)) 1567 __swig_destroy__ = _pywrapcp.delete_SearchMonitor 1568 1569 def EnterSearch(self) -> "void": 1570 r""" Beginning of the search.""" 1571 return _pywrapcp.SearchMonitor_EnterSearch(self) 1572 1573 def RestartSearch(self) -> "void": 1574 r""" Restart the search.""" 1575 return _pywrapcp.SearchMonitor_RestartSearch(self) 1576 1577 def ExitSearch(self) -> "void": 1578 r""" End of the search.""" 1579 return _pywrapcp.SearchMonitor_ExitSearch(self) 1580 1581 def BeginNextDecision(self, b: "DecisionBuilder") -> "void": 1582 r""" Before calling DecisionBuilder::Next.""" 1583 return _pywrapcp.SearchMonitor_BeginNextDecision(self, b) 1584 1585 def EndNextDecision(self, b: "DecisionBuilder", d: "Decision") -> "void": 1586 r""" After calling DecisionBuilder::Next, along with the returned decision.""" 1587 return _pywrapcp.SearchMonitor_EndNextDecision(self, b, d) 1588 1589 def ApplyDecision(self, d: "Decision") -> "void": 1590 r""" Before applying the decision.""" 1591 return _pywrapcp.SearchMonitor_ApplyDecision(self, d) 1592 1593 def RefuteDecision(self, d: "Decision") -> "void": 1594 r""" Before refuting the decision.""" 1595 return _pywrapcp.SearchMonitor_RefuteDecision(self, d) 1596 1597 def AfterDecision(self, d: "Decision", apply: "bool") -> "void": 1598 r""" Just after refuting or applying the decision, apply is true after Apply. This is called only if the Apply() or Refute() methods have not failed.""" 1599 return _pywrapcp.SearchMonitor_AfterDecision(self, d, apply) 1600 1601 def BeginFail(self) -> "void": 1602 r""" Just when the failure occurs.""" 1603 return _pywrapcp.SearchMonitor_BeginFail(self) 1604 1605 def EndFail(self) -> "void": 1606 r""" After completing the backtrack.""" 1607 return _pywrapcp.SearchMonitor_EndFail(self) 1608 1609 def BeginInitialPropagation(self) -> "void": 1610 r""" Before the initial propagation.""" 1611 return _pywrapcp.SearchMonitor_BeginInitialPropagation(self) 1612 1613 def EndInitialPropagation(self) -> "void": 1614 r""" After the initial propagation.""" 1615 return _pywrapcp.SearchMonitor_EndInitialPropagation(self) 1616 1617 def AcceptSolution(self) -> "bool": 1618 r""" This method is called when a solution is found. It asserts whether the solution is valid. A value of false indicates that the solution should be discarded.""" 1619 return _pywrapcp.SearchMonitor_AcceptSolution(self) 1620 1621 def AtSolution(self) -> "bool": 1622 r""" This method is called when a valid solution is found. If the return value is true, then search will resume after. If the result is false, then search will stop there.""" 1623 return _pywrapcp.SearchMonitor_AtSolution(self) 1624 1625 def NoMoreSolutions(self) -> "void": 1626 r""" When the search tree is finished.""" 1627 return _pywrapcp.SearchMonitor_NoMoreSolutions(self) 1628 1629 def LocalOptimum(self) -> "bool": 1630 r""" When a local optimum is reached. If 'true' is returned, the last solution is discarded and the search proceeds with the next one.""" 1631 return _pywrapcp.SearchMonitor_LocalOptimum(self) 1632 1633 def AcceptDelta(self, delta: "Assignment", deltadelta: "Assignment") -> "bool": 1634 return _pywrapcp.SearchMonitor_AcceptDelta(self, delta, deltadelta) 1635 1636 def AcceptNeighbor(self) -> "void": 1637 r""" After accepting a neighbor during local search.""" 1638 return _pywrapcp.SearchMonitor_AcceptNeighbor(self) 1639 1640 def solver(self) -> "operations_research::Solver *": 1641 return _pywrapcp.SearchMonitor_solver(self) 1642 1643 def __repr__(self) -> "std::string": 1644 return _pywrapcp.SearchMonitor___repr__(self) 1645 1646 def __str__(self) -> "std::string": 1647 return _pywrapcp.SearchMonitor___str__(self) 1648 def __disown__(self): 1649 self.this.disown() 1650 _pywrapcp.disown_SearchMonitor(self) 1651 return weakref.proxy(self)
A search monitor is a simple set of callbacks to monitor all search events
1569 def EnterSearch(self) -> "void": 1570 r""" Beginning of the search.""" 1571 return _pywrapcp.SearchMonitor_EnterSearch(self)
Beginning of the search.
1573 def RestartSearch(self) -> "void": 1574 r""" Restart the search.""" 1575 return _pywrapcp.SearchMonitor_RestartSearch(self)
Restart the search.
1577 def ExitSearch(self) -> "void": 1578 r""" End of the search.""" 1579 return _pywrapcp.SearchMonitor_ExitSearch(self)
End of the search.
1581 def BeginNextDecision(self, b: "DecisionBuilder") -> "void": 1582 r""" Before calling DecisionBuilder::Next.""" 1583 return _pywrapcp.SearchMonitor_BeginNextDecision(self, b)
Before calling DecisionBuilder::Next.
1585 def EndNextDecision(self, b: "DecisionBuilder", d: "Decision") -> "void": 1586 r""" After calling DecisionBuilder::Next, along with the returned decision.""" 1587 return _pywrapcp.SearchMonitor_EndNextDecision(self, b, d)
After calling DecisionBuilder::Next, along with the returned decision.
1589 def ApplyDecision(self, d: "Decision") -> "void": 1590 r""" Before applying the decision.""" 1591 return _pywrapcp.SearchMonitor_ApplyDecision(self, d)
Before applying the decision.
1593 def RefuteDecision(self, d: "Decision") -> "void": 1594 r""" Before refuting the decision.""" 1595 return _pywrapcp.SearchMonitor_RefuteDecision(self, d)
Before refuting the decision.
1597 def AfterDecision(self, d: "Decision", apply: "bool") -> "void": 1598 r""" Just after refuting or applying the decision, apply is true after Apply. This is called only if the Apply() or Refute() methods have not failed.""" 1599 return _pywrapcp.SearchMonitor_AfterDecision(self, d, apply)
Just after refuting or applying the decision, apply is true after Apply. This is called only if the Apply() or Refute() methods have not failed.
1601 def BeginFail(self) -> "void": 1602 r""" Just when the failure occurs.""" 1603 return _pywrapcp.SearchMonitor_BeginFail(self)
Just when the failure occurs.
1605 def EndFail(self) -> "void": 1606 r""" After completing the backtrack.""" 1607 return _pywrapcp.SearchMonitor_EndFail(self)
After completing the backtrack.
1609 def BeginInitialPropagation(self) -> "void": 1610 r""" Before the initial propagation.""" 1611 return _pywrapcp.SearchMonitor_BeginInitialPropagation(self)
Before the initial propagation.
1613 def EndInitialPropagation(self) -> "void": 1614 r""" After the initial propagation.""" 1615 return _pywrapcp.SearchMonitor_EndInitialPropagation(self)
After the initial propagation.
1617 def AcceptSolution(self) -> "bool": 1618 r""" This method is called when a solution is found. It asserts whether the solution is valid. A value of false indicates that the solution should be discarded.""" 1619 return _pywrapcp.SearchMonitor_AcceptSolution(self)
This method is called when a solution is found. It asserts whether the solution is valid. A value of false indicates that the solution should be discarded.
1621 def AtSolution(self) -> "bool": 1622 r""" This method is called when a valid solution is found. If the return value is true, then search will resume after. If the result is false, then search will stop there.""" 1623 return _pywrapcp.SearchMonitor_AtSolution(self)
This method is called when a valid solution is found. If the return value is true, then search will resume after. If the result is false, then search will stop there.
1625 def NoMoreSolutions(self) -> "void": 1626 r""" When the search tree is finished.""" 1627 return _pywrapcp.SearchMonitor_NoMoreSolutions(self)
When the search tree is finished.
1629 def LocalOptimum(self) -> "bool": 1630 r""" When a local optimum is reached. If 'true' is returned, the last solution is discarded and the search proceeds with the next one.""" 1631 return _pywrapcp.SearchMonitor_LocalOptimum(self)
When a local optimum is reached. If 'true' is returned, the last solution is discarded and the search proceeds with the next one.
1636 def AcceptNeighbor(self) -> "void": 1637 r""" After accepting a neighbor during local search.""" 1638 return _pywrapcp.SearchMonitor_AcceptNeighbor(self)
After accepting a neighbor during local search.
Inherited Members
1656class IntExpr(PropagationBaseObject): 1657 r""" The class IntExpr is the base of all integer expressions in constraint programming. It contains the basic protocol for an expression: - setting and modifying its bound - querying if it is bound - listening to events modifying its bounds - casting it into a variable (instance of IntVar)""" 1658 1659 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1660 1661 def __init__(self, *args, **kwargs): 1662 raise AttributeError("No constructor defined - class is abstract") 1663 1664 def Min(self) -> "int64_t": 1665 return _pywrapcp.IntExpr_Min(self) 1666 1667 def SetMin(self, m: "int64_t") -> "void": 1668 return _pywrapcp.IntExpr_SetMin(self, m) 1669 1670 def Max(self) -> "int64_t": 1671 return _pywrapcp.IntExpr_Max(self) 1672 1673 def SetMax(self, m: "int64_t") -> "void": 1674 return _pywrapcp.IntExpr_SetMax(self, m) 1675 1676 def SetRange(self, l: "int64_t", u: "int64_t") -> "void": 1677 r""" This method sets both the min and the max of the expression.""" 1678 return _pywrapcp.IntExpr_SetRange(self, l, u) 1679 1680 def SetValue(self, v: "int64_t") -> "void": 1681 r""" This method sets the value of the expression.""" 1682 return _pywrapcp.IntExpr_SetValue(self, v) 1683 1684 def Bound(self) -> "bool": 1685 r""" Returns true if the min and the max of the expression are equal.""" 1686 return _pywrapcp.IntExpr_Bound(self) 1687 1688 def IsVar(self) -> "bool": 1689 r""" Returns true if the expression is indeed a variable.""" 1690 return _pywrapcp.IntExpr_IsVar(self) 1691 1692 def Var(self) -> "operations_research::IntVar *": 1693 r""" Creates a variable from the expression.""" 1694 return _pywrapcp.IntExpr_Var(self) 1695 1696 def VarWithName(self, name: "std::string const &") -> "operations_research::IntVar *": 1697 r""" Creates a variable from the expression and set the name of the resulting var. If the expression is already a variable, then it will set the name of the expression, possibly overwriting it. This is just a shortcut to Var() followed by set_name().""" 1698 return _pywrapcp.IntExpr_VarWithName(self, name) 1699 1700 def WhenRange(self, *args) -> "void": 1701 r""" 1702 *Overload 1:* 1703 Attach a demon that will watch the min or the max of the expression. 1704 1705 | 1706 1707 *Overload 2:* 1708 Attach a demon that will watch the min or the max of the expression. 1709 """ 1710 return _pywrapcp.IntExpr_WhenRange(self, *args) 1711 1712 def __repr__(self) -> "std::string": 1713 return _pywrapcp.IntExpr___repr__(self) 1714 1715 def __str__(self) -> "std::string": 1716 return _pywrapcp.IntExpr___str__(self) 1717 1718 def __add__(self, *args) -> "operations_research::IntExpr *": 1719 return _pywrapcp.IntExpr___add__(self, *args) 1720 1721 def __radd__(self, v: "int64_t") -> "operations_research::IntExpr *": 1722 return _pywrapcp.IntExpr___radd__(self, v) 1723 1724 def __sub__(self, *args) -> "operations_research::IntExpr *": 1725 return _pywrapcp.IntExpr___sub__(self, *args) 1726 1727 def __rsub__(self, v: "int64_t") -> "operations_research::IntExpr *": 1728 return _pywrapcp.IntExpr___rsub__(self, v) 1729 1730 def __mul__(self, *args) -> "operations_research::IntExpr *": 1731 return _pywrapcp.IntExpr___mul__(self, *args) 1732 1733 def __rmul__(self, v: "int64_t") -> "operations_research::IntExpr *": 1734 return _pywrapcp.IntExpr___rmul__(self, v) 1735 1736 def __floordiv__(self, *args) -> "operations_research::IntExpr *": 1737 return _pywrapcp.IntExpr___floordiv__(self, *args) 1738 1739 def __mod__(self, *args) -> "operations_research::IntExpr *": 1740 return _pywrapcp.IntExpr___mod__(self, *args) 1741 1742 def __neg__(self) -> "operations_research::IntExpr *": 1743 return _pywrapcp.IntExpr___neg__(self) 1744 1745 def __abs__(self) -> "operations_research::IntExpr *": 1746 return _pywrapcp.IntExpr___abs__(self) 1747 1748 def Square(self) -> "operations_research::IntExpr *": 1749 return _pywrapcp.IntExpr_Square(self) 1750 1751 def __eq__(self, *args) -> "operations_research::Constraint *": 1752 return _pywrapcp.IntExpr___eq__(self, *args) 1753 1754 def __ne__(self, *args) -> "operations_research::Constraint *": 1755 return _pywrapcp.IntExpr___ne__(self, *args) 1756 1757 def __ge__(self, *args) -> "operations_research::Constraint *": 1758 return _pywrapcp.IntExpr___ge__(self, *args) 1759 1760 def __gt__(self, *args) -> "operations_research::Constraint *": 1761 return _pywrapcp.IntExpr___gt__(self, *args) 1762 1763 def __le__(self, *args) -> "operations_research::Constraint *": 1764 return _pywrapcp.IntExpr___le__(self, *args) 1765 1766 def __lt__(self, *args) -> "operations_research::Constraint *": 1767 return _pywrapcp.IntExpr___lt__(self, *args) 1768 1769 def MapTo(self, vars: "std::vector< operations_research::IntVar * > const &") -> "operations_research::Constraint *": 1770 return _pywrapcp.IntExpr_MapTo(self, vars) 1771 1772 def IndexOf(self, *args) -> "operations_research::IntExpr *": 1773 return _pywrapcp.IntExpr_IndexOf(self, *args) 1774 1775 def IsMember(self, values: "std::vector< int64_t > const &") -> "operations_research::IntVar *": 1776 return _pywrapcp.IntExpr_IsMember(self, values) 1777 1778 def Member(self, values: "std::vector< int64_t > const &") -> "operations_research::Constraint *": 1779 return _pywrapcp.IntExpr_Member(self, values) 1780 1781 def NotMember(self, starts: "std::vector< int64_t > const &", ends: "std::vector< int64_t > const &") -> "operations_research::Constraint *": 1782 return _pywrapcp.IntExpr_NotMember(self, starts, ends)
The class IntExpr is the base of all integer expressions in constraint programming. It contains the basic protocol for an expression: - setting and modifying its bound - querying if it is bound - listening to events modifying its bounds - casting it into a variable (instance of IntVar)
1676 def SetRange(self, l: "int64_t", u: "int64_t") -> "void": 1677 r""" This method sets both the min and the max of the expression.""" 1678 return _pywrapcp.IntExpr_SetRange(self, l, u)
This method sets both the min and the max of the expression.
1680 def SetValue(self, v: "int64_t") -> "void": 1681 r""" This method sets the value of the expression.""" 1682 return _pywrapcp.IntExpr_SetValue(self, v)
This method sets the value of the expression.
1684 def Bound(self) -> "bool": 1685 r""" Returns true if the min and the max of the expression are equal.""" 1686 return _pywrapcp.IntExpr_Bound(self)
Returns true if the min and the max of the expression are equal.
1688 def IsVar(self) -> "bool": 1689 r""" Returns true if the expression is indeed a variable.""" 1690 return _pywrapcp.IntExpr_IsVar(self)
Returns true if the expression is indeed a variable.
1692 def Var(self) -> "operations_research::IntVar *": 1693 r""" Creates a variable from the expression.""" 1694 return _pywrapcp.IntExpr_Var(self)
Creates a variable from the expression.
1696 def VarWithName(self, name: "std::string const &") -> "operations_research::IntVar *": 1697 r""" Creates a variable from the expression and set the name of the resulting var. If the expression is already a variable, then it will set the name of the expression, possibly overwriting it. This is just a shortcut to Var() followed by set_name().""" 1698 return _pywrapcp.IntExpr_VarWithName(self, name)
Creates a variable from the expression and set the name of the resulting var. If the expression is already a variable, then it will set the name of the expression, possibly overwriting it. This is just a shortcut to Var() followed by set_name().
1700 def WhenRange(self, *args) -> "void": 1701 r""" 1702 *Overload 1:* 1703 Attach a demon that will watch the min or the max of the expression. 1704 1705 | 1706 1707 *Overload 2:* 1708 Attach a demon that will watch the min or the max of the expression. 1709 """ 1710 return _pywrapcp.IntExpr_WhenRange(self, *args)
Overload 1: Attach a demon that will watch the min or the max of the expression.
|
Overload 2: Attach a demon that will watch the min or the max of the expression.
Inherited Members
1787class IntVarIterator(BaseObject): 1788 r""" The class Iterator has two direct subclasses. HoleIterators iterates over all holes, that is value removed between the current min and max of the variable since the last time the variable was processed in the queue. DomainIterators iterates over all elements of the variable domain. Both iterators are not robust to domain changes. Hole iterators can also report values outside the current min and max of the variable. HoleIterators should only be called from a demon attached to the variable that has created this iterator. IntVar* current_var; std::unique_ptr<IntVarIterator> it(current_var->MakeHoleIterator(false)); for (const int64_t hole : InitAndGetValues(it)) { /// use the hole }""" 1789 1790 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1791 1792 def __init__(self, *args, **kwargs): 1793 raise AttributeError("No constructor defined - class is abstract") 1794 __repr__ = _swig_repr 1795 1796 def Init(self) -> "void": 1797 r""" This method must be called before each loop.""" 1798 return _pywrapcp.IntVarIterator_Init(self) 1799 1800 def Ok(self) -> "bool": 1801 r""" This method indicates if we can call Value() or not.""" 1802 return _pywrapcp.IntVarIterator_Ok(self) 1803 1804 def Value(self) -> "int64_t": 1805 r""" This method returns the current value of the iterator.""" 1806 return _pywrapcp.IntVarIterator_Value(self) 1807 1808 def Next(self) -> "void": 1809 r""" This method moves the iterator to the next value.""" 1810 return _pywrapcp.IntVarIterator_Next(self) 1811 1812 def DebugString(self) -> "std::string": 1813 r""" Pretty Print.""" 1814 return _pywrapcp.IntVarIterator_DebugString(self) 1815 1816 def __iter__(self): 1817 self.Init() 1818 return self 1819 1820 def next(self): 1821 if self.Ok(): 1822 result = self.Value() 1823 self.Next() 1824 return result 1825 else: 1826 raise StopIteration() 1827 1828 def __next__(self): 1829 return self.next()
The class Iterator has two direct subclasses. HoleIterators iterates over all holes, that is value removed between the current min and max of the variable since the last time the variable was processed in the queue. DomainIterators iterates over all elements of the variable domain. Both iterators are not robust to domain changes. Hole iterators can also report values outside the current min and max of the variable. HoleIterators should only be called from a demon attached to the variable that has created this iterator. IntVar* current_var; std::unique_ptr
1796 def Init(self) -> "void": 1797 r""" This method must be called before each loop.""" 1798 return _pywrapcp.IntVarIterator_Init(self)
This method must be called before each loop.
1800 def Ok(self) -> "bool": 1801 r""" This method indicates if we can call Value() or not.""" 1802 return _pywrapcp.IntVarIterator_Ok(self)
This method indicates if we can call Value() or not.
1804 def Value(self) -> "int64_t": 1805 r""" This method returns the current value of the iterator.""" 1806 return _pywrapcp.IntVarIterator_Value(self)
This method returns the current value of the iterator.
1808 def Next(self) -> "void": 1809 r""" This method moves the iterator to the next value.""" 1810 return _pywrapcp.IntVarIterator_Next(self)
This method moves the iterator to the next value.
1835class IntVar(IntExpr): 1836 r""" The class IntVar is a subset of IntExpr. In addition to the IntExpr protocol, it offers persistence, removing values from the domains, and a finer model for events.""" 1837 1838 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1839 1840 def __init__(self, *args, **kwargs): 1841 raise AttributeError("No constructor defined - class is abstract") 1842 1843 def IsVar(self) -> "bool": 1844 return _pywrapcp.IntVar_IsVar(self) 1845 1846 def Var(self) -> "operations_research::IntVar *": 1847 return _pywrapcp.IntVar_Var(self) 1848 1849 def Value(self) -> "int64_t": 1850 r""" This method returns the value of the variable. This method checks before that the variable is bound.""" 1851 return _pywrapcp.IntVar_Value(self) 1852 1853 def RemoveValue(self, v: "int64_t") -> "void": 1854 r""" This method removes the value 'v' from the domain of the variable.""" 1855 return _pywrapcp.IntVar_RemoveValue(self, v) 1856 1857 def RemoveInterval(self, l: "int64_t", u: "int64_t") -> "void": 1858 r""" This method removes the interval 'l' .. 'u' from the domain of the variable. It assumes that 'l' <= 'u'.""" 1859 return _pywrapcp.IntVar_RemoveInterval(self, l, u) 1860 1861 def RemoveValues(self, values: "std::vector< int64_t > const &") -> "void": 1862 r""" This method remove the values from the domain of the variable.""" 1863 return _pywrapcp.IntVar_RemoveValues(self, values) 1864 1865 def SetValues(self, values: "std::vector< int64_t > const &") -> "void": 1866 r""" This method intersects the current domain with the values in the array.""" 1867 return _pywrapcp.IntVar_SetValues(self, values) 1868 1869 def WhenBound(self, *args) -> "void": 1870 r""" 1871 *Overload 1:* 1872 This method attaches a demon that will be awakened when the variable is bound. 1873 1874 | 1875 1876 *Overload 2:* 1877 This method attaches a closure that will be awakened when the variable is bound. 1878 """ 1879 return _pywrapcp.IntVar_WhenBound(self, *args) 1880 1881 def WhenDomain(self, *args) -> "void": 1882 r""" 1883 *Overload 1:* 1884 This method attaches a demon that will watch any domain modification of the domain of the variable. 1885 1886 | 1887 1888 *Overload 2:* 1889 This method attaches a closure that will watch any domain modification of the domain of the variable. 1890 """ 1891 return _pywrapcp.IntVar_WhenDomain(self, *args) 1892 1893 def Size(self) -> "uint64_t": 1894 r""" This method returns the number of values in the domain of the variable.""" 1895 return _pywrapcp.IntVar_Size(self) 1896 1897 def Contains(self, v: "int64_t") -> "bool": 1898 r""" This method returns whether the value 'v' is in the domain of the variable.""" 1899 return _pywrapcp.IntVar_Contains(self, v) 1900 1901 def HoleIteratorAux(self, reversible: "bool") -> "operations_research::IntVarIterator *": 1902 r""" Creates a hole iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.""" 1903 return _pywrapcp.IntVar_HoleIteratorAux(self, reversible) 1904 1905 def DomainIteratorAux(self, reversible: "bool") -> "operations_research::IntVarIterator *": 1906 r""" Creates a domain iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.""" 1907 return _pywrapcp.IntVar_DomainIteratorAux(self, reversible) 1908 1909 def OldMin(self) -> "int64_t": 1910 r""" Returns the previous min.""" 1911 return _pywrapcp.IntVar_OldMin(self) 1912 1913 def OldMax(self) -> "int64_t": 1914 r""" Returns the previous max.""" 1915 return _pywrapcp.IntVar_OldMax(self) 1916 1917 def __repr__(self) -> "std::string": 1918 return _pywrapcp.IntVar___repr__(self) 1919 1920 def __str__(self) -> "std::string": 1921 return _pywrapcp.IntVar___str__(self) 1922 1923 def DomainIterator(self): 1924 return iter(self.DomainIteratorAux(False)) 1925 1926 def HoleIterator(self): 1927 return iter(self.HoleIteratorAux(False))
The class IntVar is a subset of IntExpr. In addition to the IntExpr protocol, it offers persistence, removing values from the domains, and a finer model for events.
1849 def Value(self) -> "int64_t": 1850 r""" This method returns the value of the variable. This method checks before that the variable is bound.""" 1851 return _pywrapcp.IntVar_Value(self)
This method returns the value of the variable. This method checks before that the variable is bound.
1853 def RemoveValue(self, v: "int64_t") -> "void": 1854 r""" This method removes the value 'v' from the domain of the variable.""" 1855 return _pywrapcp.IntVar_RemoveValue(self, v)
This method removes the value 'v' from the domain of the variable.
1857 def RemoveInterval(self, l: "int64_t", u: "int64_t") -> "void": 1858 r""" This method removes the interval 'l' .. 'u' from the domain of the variable. It assumes that 'l' <= 'u'.""" 1859 return _pywrapcp.IntVar_RemoveInterval(self, l, u)
This method removes the interval 'l' .. 'u' from the domain of the variable. It assumes that 'l' <= 'u'.
1861 def RemoveValues(self, values: "std::vector< int64_t > const &") -> "void": 1862 r""" This method remove the values from the domain of the variable.""" 1863 return _pywrapcp.IntVar_RemoveValues(self, values)
This method remove the values from the domain of the variable.
1865 def SetValues(self, values: "std::vector< int64_t > const &") -> "void": 1866 r""" This method intersects the current domain with the values in the array.""" 1867 return _pywrapcp.IntVar_SetValues(self, values)
This method intersects the current domain with the values in the array.
1869 def WhenBound(self, *args) -> "void": 1870 r""" 1871 *Overload 1:* 1872 This method attaches a demon that will be awakened when the variable is bound. 1873 1874 | 1875 1876 *Overload 2:* 1877 This method attaches a closure that will be awakened when the variable is bound. 1878 """ 1879 return _pywrapcp.IntVar_WhenBound(self, *args)
Overload 1: This method attaches a demon that will be awakened when the variable is bound.
|
Overload 2: This method attaches a closure that will be awakened when the variable is bound.
1881 def WhenDomain(self, *args) -> "void": 1882 r""" 1883 *Overload 1:* 1884 This method attaches a demon that will watch any domain modification of the domain of the variable. 1885 1886 | 1887 1888 *Overload 2:* 1889 This method attaches a closure that will watch any domain modification of the domain of the variable. 1890 """ 1891 return _pywrapcp.IntVar_WhenDomain(self, *args)
Overload 1: This method attaches a demon that will watch any domain modification of the domain of the variable.
|
Overload 2: This method attaches a closure that will watch any domain modification of the domain of the variable.
1893 def Size(self) -> "uint64_t": 1894 r""" This method returns the number of values in the domain of the variable.""" 1895 return _pywrapcp.IntVar_Size(self)
This method returns the number of values in the domain of the variable.
1897 def Contains(self, v: "int64_t") -> "bool": 1898 r""" This method returns whether the value 'v' is in the domain of the variable.""" 1899 return _pywrapcp.IntVar_Contains(self, v)
This method returns whether the value 'v' is in the domain of the variable.
1901 def HoleIteratorAux(self, reversible: "bool") -> "operations_research::IntVarIterator *": 1902 r""" Creates a hole iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.""" 1903 return _pywrapcp.IntVar_HoleIteratorAux(self, reversible)
Creates a hole iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.
1905 def DomainIteratorAux(self, reversible: "bool") -> "operations_research::IntVarIterator *": 1906 r""" Creates a domain iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.""" 1907 return _pywrapcp.IntVar_DomainIteratorAux(self, reversible)
Creates a domain iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.
1909 def OldMin(self) -> "int64_t": 1910 r""" Returns the previous min.""" 1911 return _pywrapcp.IntVar_OldMin(self)
Returns the previous min.
1913 def OldMax(self) -> "int64_t": 1914 r""" Returns the previous max.""" 1915 return _pywrapcp.IntVar_OldMax(self)
Returns the previous max.
1933class SolutionCollector(SearchMonitor): 1934 r""" This class is the root class of all solution collectors. It implements a basic query API to be used independently of the collector used.""" 1935 1936 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 1937 1938 def __init__(self, *args, **kwargs): 1939 raise AttributeError("No constructor defined") 1940 __repr__ = _swig_repr 1941 1942 def DebugString(self) -> "std::string": 1943 return _pywrapcp.SolutionCollector_DebugString(self) 1944 1945 def Add(self, *args) -> "void": 1946 return _pywrapcp.SolutionCollector_Add(self, *args) 1947 1948 def AddObjective(self, objective: "IntVar") -> "void": 1949 return _pywrapcp.SolutionCollector_AddObjective(self, objective) 1950 1951 def EnterSearch(self) -> "void": 1952 r""" Beginning of the search.""" 1953 return _pywrapcp.SolutionCollector_EnterSearch(self) 1954 1955 def SolutionCount(self) -> "int": 1956 r""" Returns how many solutions were stored during the search.""" 1957 return _pywrapcp.SolutionCollector_SolutionCount(self) 1958 1959 def Solution(self, n: "int") -> "operations_research::Assignment *": 1960 r""" Returns the nth solution.""" 1961 return _pywrapcp.SolutionCollector_Solution(self, n) 1962 1963 def WallTime(self, n: "int") -> "int64_t": 1964 r""" Returns the wall time in ms for the nth solution.""" 1965 return _pywrapcp.SolutionCollector_WallTime(self, n) 1966 1967 def Branches(self, n: "int") -> "int64_t": 1968 r""" Returns the number of branches when the nth solution was found.""" 1969 return _pywrapcp.SolutionCollector_Branches(self, n) 1970 1971 def Failures(self, n: "int") -> "int64_t": 1972 r""" Returns the number of failures encountered at the time of the nth solution.""" 1973 return _pywrapcp.SolutionCollector_Failures(self, n) 1974 1975 def ObjectiveValue(self, n: "int") -> "int64_t": 1976 r""" Returns the objective value of the nth solution.""" 1977 return _pywrapcp.SolutionCollector_ObjectiveValue(self, n) 1978 1979 def Value(self, n: "int", var: "IntVar") -> "int64_t": 1980 r""" This is a shortcut to get the Value of 'var' in the nth solution.""" 1981 return _pywrapcp.SolutionCollector_Value(self, n, var) 1982 1983 def StartValue(self, n: "int", var: "IntervalVar") -> "int64_t": 1984 r""" This is a shortcut to get the StartValue of 'var' in the nth solution.""" 1985 return _pywrapcp.SolutionCollector_StartValue(self, n, var) 1986 1987 def EndValue(self, n: "int", var: "IntervalVar") -> "int64_t": 1988 r""" This is a shortcut to get the EndValue of 'var' in the nth solution.""" 1989 return _pywrapcp.SolutionCollector_EndValue(self, n, var) 1990 1991 def DurationValue(self, n: "int", var: "IntervalVar") -> "int64_t": 1992 r""" This is a shortcut to get the DurationValue of 'var' in the nth solution.""" 1993 return _pywrapcp.SolutionCollector_DurationValue(self, n, var) 1994 1995 def PerformedValue(self, n: "int", var: "IntervalVar") -> "int64_t": 1996 r""" This is a shortcut to get the PerformedValue of 'var' in the nth solution.""" 1997 return _pywrapcp.SolutionCollector_PerformedValue(self, n, var) 1998 1999 def ForwardSequence(self, n: "int", var: "SequenceVar") -> "std::vector< int > const &": 2000 r""" This is a shortcut to get the ForwardSequence of 'var' in the nth solution. The forward sequence is the list of ranked interval variables starting from the start of the sequence.""" 2001 return _pywrapcp.SolutionCollector_ForwardSequence(self, n, var) 2002 2003 def BackwardSequence(self, n: "int", var: "SequenceVar") -> "std::vector< int > const &": 2004 r""" This is a shortcut to get the BackwardSequence of 'var' in the nth solution. The backward sequence is the list of ranked interval variables starting from the end of the sequence.""" 2005 return _pywrapcp.SolutionCollector_BackwardSequence(self, n, var) 2006 2007 def Unperformed(self, n: "int", var: "SequenceVar") -> "std::vector< int > const &": 2008 r""" This is a shortcut to get the list of unperformed of 'var' in the nth solution.""" 2009 return _pywrapcp.SolutionCollector_Unperformed(self, n, var)
This class is the root class of all solution collectors. It implements a basic query API to be used independently of the collector used.
1951 def EnterSearch(self) -> "void": 1952 r""" Beginning of the search.""" 1953 return _pywrapcp.SolutionCollector_EnterSearch(self)
Beginning of the search.
1955 def SolutionCount(self) -> "int": 1956 r""" Returns how many solutions were stored during the search.""" 1957 return _pywrapcp.SolutionCollector_SolutionCount(self)
Returns how many solutions were stored during the search.
1959 def Solution(self, n: "int") -> "operations_research::Assignment *": 1960 r""" Returns the nth solution.""" 1961 return _pywrapcp.SolutionCollector_Solution(self, n)
Returns the nth solution.
1963 def WallTime(self, n: "int") -> "int64_t": 1964 r""" Returns the wall time in ms for the nth solution.""" 1965 return _pywrapcp.SolutionCollector_WallTime(self, n)
Returns the wall time in ms for the nth solution.
1967 def Branches(self, n: "int") -> "int64_t": 1968 r""" Returns the number of branches when the nth solution was found.""" 1969 return _pywrapcp.SolutionCollector_Branches(self, n)
Returns the number of branches when the nth solution was found.
1971 def Failures(self, n: "int") -> "int64_t": 1972 r""" Returns the number of failures encountered at the time of the nth solution.""" 1973 return _pywrapcp.SolutionCollector_Failures(self, n)
Returns the number of failures encountered at the time of the nth solution.
1975 def ObjectiveValue(self, n: "int") -> "int64_t": 1976 r""" Returns the objective value of the nth solution.""" 1977 return _pywrapcp.SolutionCollector_ObjectiveValue(self, n)
Returns the objective value of the nth solution.
1979 def Value(self, n: "int", var: "IntVar") -> "int64_t": 1980 r""" This is a shortcut to get the Value of 'var' in the nth solution.""" 1981 return _pywrapcp.SolutionCollector_Value(self, n, var)
This is a shortcut to get the Value of 'var' in the nth solution.
1983 def StartValue(self, n: "int", var: "IntervalVar") -> "int64_t": 1984 r""" This is a shortcut to get the StartValue of 'var' in the nth solution.""" 1985 return _pywrapcp.SolutionCollector_StartValue(self, n, var)
This is a shortcut to get the StartValue of 'var' in the nth solution.
1987 def EndValue(self, n: "int", var: "IntervalVar") -> "int64_t": 1988 r""" This is a shortcut to get the EndValue of 'var' in the nth solution.""" 1989 return _pywrapcp.SolutionCollector_EndValue(self, n, var)
This is a shortcut to get the EndValue of 'var' in the nth solution.
1991 def DurationValue(self, n: "int", var: "IntervalVar") -> "int64_t": 1992 r""" This is a shortcut to get the DurationValue of 'var' in the nth solution.""" 1993 return _pywrapcp.SolutionCollector_DurationValue(self, n, var)
This is a shortcut to get the DurationValue of 'var' in the nth solution.
1995 def PerformedValue(self, n: "int", var: "IntervalVar") -> "int64_t": 1996 r""" This is a shortcut to get the PerformedValue of 'var' in the nth solution.""" 1997 return _pywrapcp.SolutionCollector_PerformedValue(self, n, var)
This is a shortcut to get the PerformedValue of 'var' in the nth solution.
1999 def ForwardSequence(self, n: "int", var: "SequenceVar") -> "std::vector< int > const &": 2000 r""" This is a shortcut to get the ForwardSequence of 'var' in the nth solution. The forward sequence is the list of ranked interval variables starting from the start of the sequence.""" 2001 return _pywrapcp.SolutionCollector_ForwardSequence(self, n, var)
This is a shortcut to get the ForwardSequence of 'var' in the nth solution. The forward sequence is the list of ranked interval variables starting from the start of the sequence.
2003 def BackwardSequence(self, n: "int", var: "SequenceVar") -> "std::vector< int > const &": 2004 r""" This is a shortcut to get the BackwardSequence of 'var' in the nth solution. The backward sequence is the list of ranked interval variables starting from the end of the sequence.""" 2005 return _pywrapcp.SolutionCollector_BackwardSequence(self, n, var)
This is a shortcut to get the BackwardSequence of 'var' in the nth solution. The backward sequence is the list of ranked interval variables starting from the end of the sequence.
2007 def Unperformed(self, n: "int", var: "SequenceVar") -> "std::vector< int > const &": 2008 r""" This is a shortcut to get the list of unperformed of 'var' in the nth solution.""" 2009 return _pywrapcp.SolutionCollector_Unperformed(self, n, var)
This is a shortcut to get the list of unperformed of 'var' in the nth solution.
2014class OptimizeVar(SearchMonitor): 2015 r""" This class encapsulates an objective. It requires the direction (minimize or maximize), the variable to optimize, and the improvement step.""" 2016 2017 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2018 2019 def __init__(self, *args, **kwargs): 2020 raise AttributeError("No constructor defined") 2021 __repr__ = _swig_repr 2022 2023 def Best(self) -> "int64_t": 2024 r""" Returns the best value found during search.""" 2025 return _pywrapcp.OptimizeVar_Best(self) 2026 2027 def Var(self) -> "operations_research::IntVar *": 2028 r""" Returns the variable that is optimized.""" 2029 return _pywrapcp.OptimizeVar_Var(self) 2030 2031 def AcceptDelta(self, delta: "Assignment", deltadelta: "Assignment") -> "bool": 2032 r""" Internal methods.""" 2033 return _pywrapcp.OptimizeVar_AcceptDelta(self, delta, deltadelta) 2034 2035 def EnterSearch(self) -> "void": 2036 return _pywrapcp.OptimizeVar_EnterSearch(self) 2037 2038 def BeginNextDecision(self, db: "DecisionBuilder") -> "void": 2039 return _pywrapcp.OptimizeVar_BeginNextDecision(self, db) 2040 2041 def RefuteDecision(self, d: "Decision") -> "void": 2042 return _pywrapcp.OptimizeVar_RefuteDecision(self, d) 2043 2044 def AtSolution(self) -> "bool": 2045 return _pywrapcp.OptimizeVar_AtSolution(self) 2046 2047 def AcceptSolution(self) -> "bool": 2048 return _pywrapcp.OptimizeVar_AcceptSolution(self) 2049 2050 def DebugString(self) -> "std::string": 2051 return _pywrapcp.OptimizeVar_DebugString(self)
This class encapsulates an objective. It requires the direction (minimize or maximize), the variable to optimize, and the improvement step.
2023 def Best(self) -> "int64_t": 2024 r""" Returns the best value found during search.""" 2025 return _pywrapcp.OptimizeVar_Best(self)
Returns the best value found during search.
2027 def Var(self) -> "operations_research::IntVar *": 2028 r""" Returns the variable that is optimized.""" 2029 return _pywrapcp.OptimizeVar_Var(self)
Returns the variable that is optimized.
2031 def AcceptDelta(self, delta: "Assignment", deltadelta: "Assignment") -> "bool": 2032 r""" Internal methods.""" 2033 return _pywrapcp.OptimizeVar_AcceptDelta(self, delta, deltadelta)
Internal methods.
2038 def BeginNextDecision(self, db: "DecisionBuilder") -> "void": 2039 return _pywrapcp.OptimizeVar_BeginNextDecision(self, db)
Before calling DecisionBuilder::Next.
2041 def RefuteDecision(self, d: "Decision") -> "void": 2042 return _pywrapcp.OptimizeVar_RefuteDecision(self, d)
Before refuting the decision.
This method is called when a valid solution is found. If the return value is true, then search will resume after. If the result is false, then search will stop there.
This method is called when a solution is found. It asserts whether the solution is valid. A value of false indicates that the solution should be discarded.
2056class SearchLimit(SearchMonitor): 2057 r""" Base class of all search limits.""" 2058 2059 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2060 2061 def __init__(self, *args, **kwargs): 2062 raise AttributeError("No constructor defined - class is abstract") 2063 __repr__ = _swig_repr 2064 __swig_destroy__ = _pywrapcp.delete_SearchLimit 2065 2066 def Crossed(self) -> "bool": 2067 r""" Returns true if the limit has been crossed.""" 2068 return _pywrapcp.SearchLimit_Crossed(self) 2069 2070 def Check(self) -> "bool": 2071 r""" This method is called to check the status of the limit. A return value of true indicates that we have indeed crossed the limit. In that case, this method will not be called again and the remaining search will be discarded.""" 2072 return _pywrapcp.SearchLimit_Check(self) 2073 2074 def Init(self) -> "void": 2075 r""" This method is called when the search limit is initialized.""" 2076 return _pywrapcp.SearchLimit_Init(self) 2077 2078 def EnterSearch(self) -> "void": 2079 r""" Internal methods.""" 2080 return _pywrapcp.SearchLimit_EnterSearch(self) 2081 2082 def BeginNextDecision(self, b: "DecisionBuilder") -> "void": 2083 return _pywrapcp.SearchLimit_BeginNextDecision(self, b) 2084 2085 def RefuteDecision(self, d: "Decision") -> "void": 2086 return _pywrapcp.SearchLimit_RefuteDecision(self, d) 2087 2088 def DebugString(self) -> "std::string": 2089 return _pywrapcp.SearchLimit_DebugString(self)
Base class of all search limits.
2066 def Crossed(self) -> "bool": 2067 r""" Returns true if the limit has been crossed.""" 2068 return _pywrapcp.SearchLimit_Crossed(self)
Returns true if the limit has been crossed.
2070 def Check(self) -> "bool": 2071 r""" This method is called to check the status of the limit. A return value of true indicates that we have indeed crossed the limit. In that case, this method will not be called again and the remaining search will be discarded.""" 2072 return _pywrapcp.SearchLimit_Check(self)
This method is called to check the status of the limit. A return value of true indicates that we have indeed crossed the limit. In that case, this method will not be called again and the remaining search will be discarded.
2074 def Init(self) -> "void": 2075 r""" This method is called when the search limit is initialized.""" 2076 return _pywrapcp.SearchLimit_Init(self)
This method is called when the search limit is initialized.
2078 def EnterSearch(self) -> "void": 2079 r""" Internal methods.""" 2080 return _pywrapcp.SearchLimit_EnterSearch(self)
Internal methods.
2082 def BeginNextDecision(self, b: "DecisionBuilder") -> "void": 2083 return _pywrapcp.SearchLimit_BeginNextDecision(self, b)
Before calling DecisionBuilder::Next.
2085 def RefuteDecision(self, d: "Decision") -> "void": 2086 return _pywrapcp.SearchLimit_RefuteDecision(self, d)
Before refuting the decision.
2094class IntervalVar(PropagationBaseObject): 2095 r""" Interval variables are often used in scheduling. The main characteristics of an IntervalVar are the start position, duration, and end date. All these characteristics can be queried and set, and demons can be posted on their modifications. An important aspect is optionality: an IntervalVar can be performed or not. If unperformed, then it simply does not exist, and its characteristics cannot be accessed any more. An interval var is automatically marked as unperformed when it is not consistent anymore (start greater than end, duration < 0...)""" 2096 2097 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2098 2099 def __init__(self, *args, **kwargs): 2100 raise AttributeError("No constructor defined - class is abstract") 2101 2102 def StartMin(self) -> "int64_t": 2103 r""" These methods query, set, and watch the start position of the interval var.""" 2104 return _pywrapcp.IntervalVar_StartMin(self) 2105 2106 def StartMax(self) -> "int64_t": 2107 return _pywrapcp.IntervalVar_StartMax(self) 2108 2109 def SetStartMin(self, m: "int64_t") -> "void": 2110 return _pywrapcp.IntervalVar_SetStartMin(self, m) 2111 2112 def SetStartMax(self, m: "int64_t") -> "void": 2113 return _pywrapcp.IntervalVar_SetStartMax(self, m) 2114 2115 def SetStartRange(self, mi: "int64_t", ma: "int64_t") -> "void": 2116 return _pywrapcp.IntervalVar_SetStartRange(self, mi, ma) 2117 2118 def OldStartMin(self) -> "int64_t": 2119 return _pywrapcp.IntervalVar_OldStartMin(self) 2120 2121 def OldStartMax(self) -> "int64_t": 2122 return _pywrapcp.IntervalVar_OldStartMax(self) 2123 2124 def WhenStartRange(self, *args) -> "void": 2125 return _pywrapcp.IntervalVar_WhenStartRange(self, *args) 2126 2127 def WhenStartBound(self, *args) -> "void": 2128 return _pywrapcp.IntervalVar_WhenStartBound(self, *args) 2129 2130 def DurationMin(self) -> "int64_t": 2131 r""" These methods query, set, and watch the duration of the interval var.""" 2132 return _pywrapcp.IntervalVar_DurationMin(self) 2133 2134 def DurationMax(self) -> "int64_t": 2135 return _pywrapcp.IntervalVar_DurationMax(self) 2136 2137 def SetDurationMin(self, m: "int64_t") -> "void": 2138 return _pywrapcp.IntervalVar_SetDurationMin(self, m) 2139 2140 def SetDurationMax(self, m: "int64_t") -> "void": 2141 return _pywrapcp.IntervalVar_SetDurationMax(self, m) 2142 2143 def SetDurationRange(self, mi: "int64_t", ma: "int64_t") -> "void": 2144 return _pywrapcp.IntervalVar_SetDurationRange(self, mi, ma) 2145 2146 def OldDurationMin(self) -> "int64_t": 2147 return _pywrapcp.IntervalVar_OldDurationMin(self) 2148 2149 def OldDurationMax(self) -> "int64_t": 2150 return _pywrapcp.IntervalVar_OldDurationMax(self) 2151 2152 def WhenDurationRange(self, *args) -> "void": 2153 return _pywrapcp.IntervalVar_WhenDurationRange(self, *args) 2154 2155 def WhenDurationBound(self, *args) -> "void": 2156 return _pywrapcp.IntervalVar_WhenDurationBound(self, *args) 2157 2158 def EndMin(self) -> "int64_t": 2159 r""" These methods query, set, and watch the end position of the interval var.""" 2160 return _pywrapcp.IntervalVar_EndMin(self) 2161 2162 def EndMax(self) -> "int64_t": 2163 return _pywrapcp.IntervalVar_EndMax(self) 2164 2165 def SetEndMin(self, m: "int64_t") -> "void": 2166 return _pywrapcp.IntervalVar_SetEndMin(self, m) 2167 2168 def SetEndMax(self, m: "int64_t") -> "void": 2169 return _pywrapcp.IntervalVar_SetEndMax(self, m) 2170 2171 def SetEndRange(self, mi: "int64_t", ma: "int64_t") -> "void": 2172 return _pywrapcp.IntervalVar_SetEndRange(self, mi, ma) 2173 2174 def OldEndMin(self) -> "int64_t": 2175 return _pywrapcp.IntervalVar_OldEndMin(self) 2176 2177 def OldEndMax(self) -> "int64_t": 2178 return _pywrapcp.IntervalVar_OldEndMax(self) 2179 2180 def WhenEndRange(self, *args) -> "void": 2181 return _pywrapcp.IntervalVar_WhenEndRange(self, *args) 2182 2183 def WhenEndBound(self, *args) -> "void": 2184 return _pywrapcp.IntervalVar_WhenEndBound(self, *args) 2185 2186 def MustBePerformed(self) -> "bool": 2187 r""" These methods query, set, and watch the performed status of the interval var.""" 2188 return _pywrapcp.IntervalVar_MustBePerformed(self) 2189 2190 def MayBePerformed(self) -> "bool": 2191 return _pywrapcp.IntervalVar_MayBePerformed(self) 2192 2193 def CannotBePerformed(self) -> "bool": 2194 return _pywrapcp.IntervalVar_CannotBePerformed(self) 2195 2196 def IsPerformedBound(self) -> "bool": 2197 return _pywrapcp.IntervalVar_IsPerformedBound(self) 2198 2199 def SetPerformed(self, val: "bool") -> "void": 2200 return _pywrapcp.IntervalVar_SetPerformed(self, val) 2201 2202 def WasPerformedBound(self) -> "bool": 2203 return _pywrapcp.IntervalVar_WasPerformedBound(self) 2204 2205 def WhenPerformedBound(self, *args) -> "void": 2206 return _pywrapcp.IntervalVar_WhenPerformedBound(self, *args) 2207 2208 def WhenAnything(self, *args) -> "void": 2209 r""" 2210 *Overload 1:* 2211 Attaches a demon awakened when anything about this interval changes. 2212 2213 | 2214 2215 *Overload 2:* 2216 Attaches a closure awakened when anything about this interval changes. 2217 """ 2218 return _pywrapcp.IntervalVar_WhenAnything(self, *args) 2219 2220 def StartExpr(self) -> "operations_research::IntExpr *": 2221 r""" These methods create expressions encapsulating the start, end and duration of the interval var. Please note that these must not be used if the interval var is unperformed.""" 2222 return _pywrapcp.IntervalVar_StartExpr(self) 2223 2224 def DurationExpr(self) -> "operations_research::IntExpr *": 2225 return _pywrapcp.IntervalVar_DurationExpr(self) 2226 2227 def EndExpr(self) -> "operations_research::IntExpr *": 2228 return _pywrapcp.IntervalVar_EndExpr(self) 2229 2230 def PerformedExpr(self) -> "operations_research::IntExpr *": 2231 return _pywrapcp.IntervalVar_PerformedExpr(self) 2232 2233 def SafeStartExpr(self, unperformed_value: "int64_t") -> "operations_research::IntExpr *": 2234 r""" These methods create expressions encapsulating the start, end and duration of the interval var. If the interval var is unperformed, they will return the unperformed_value.""" 2235 return _pywrapcp.IntervalVar_SafeStartExpr(self, unperformed_value) 2236 2237 def SafeDurationExpr(self, unperformed_value: "int64_t") -> "operations_research::IntExpr *": 2238 return _pywrapcp.IntervalVar_SafeDurationExpr(self, unperformed_value) 2239 2240 def SafeEndExpr(self, unperformed_value: "int64_t") -> "operations_research::IntExpr *": 2241 return _pywrapcp.IntervalVar_SafeEndExpr(self, unperformed_value) 2242 2243 def EndsAfterEnd(self, other: "IntervalVar") -> "operations_research::Constraint *": 2244 return _pywrapcp.IntervalVar_EndsAfterEnd(self, other) 2245 2246 def EndsAfterEndWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2247 return _pywrapcp.IntervalVar_EndsAfterEndWithDelay(self, other, delay) 2248 2249 def EndsAfterStart(self, other: "IntervalVar") -> "operations_research::Constraint *": 2250 return _pywrapcp.IntervalVar_EndsAfterStart(self, other) 2251 2252 def EndsAfterStartWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2253 return _pywrapcp.IntervalVar_EndsAfterStartWithDelay(self, other, delay) 2254 2255 def EndsAtEnd(self, other: "IntervalVar") -> "operations_research::Constraint *": 2256 return _pywrapcp.IntervalVar_EndsAtEnd(self, other) 2257 2258 def EndsAtEndWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2259 return _pywrapcp.IntervalVar_EndsAtEndWithDelay(self, other, delay) 2260 2261 def EndsAtStart(self, other: "IntervalVar") -> "operations_research::Constraint *": 2262 return _pywrapcp.IntervalVar_EndsAtStart(self, other) 2263 2264 def EndsAtStartWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2265 return _pywrapcp.IntervalVar_EndsAtStartWithDelay(self, other, delay) 2266 2267 def StartsAfterEnd(self, other: "IntervalVar") -> "operations_research::Constraint *": 2268 return _pywrapcp.IntervalVar_StartsAfterEnd(self, other) 2269 2270 def StartsAfterEndWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2271 return _pywrapcp.IntervalVar_StartsAfterEndWithDelay(self, other, delay) 2272 2273 def StartsAfterStart(self, other: "IntervalVar") -> "operations_research::Constraint *": 2274 return _pywrapcp.IntervalVar_StartsAfterStart(self, other) 2275 2276 def StartsAfterStartWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2277 return _pywrapcp.IntervalVar_StartsAfterStartWithDelay(self, other, delay) 2278 2279 def StartsAtEnd(self, other: "IntervalVar") -> "operations_research::Constraint *": 2280 return _pywrapcp.IntervalVar_StartsAtEnd(self, other) 2281 2282 def StartsAtEndWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2283 return _pywrapcp.IntervalVar_StartsAtEndWithDelay(self, other, delay) 2284 2285 def StartsAtStart(self, other: "IntervalVar") -> "operations_research::Constraint *": 2286 return _pywrapcp.IntervalVar_StartsAtStart(self, other) 2287 2288 def StartsAtStartWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2289 return _pywrapcp.IntervalVar_StartsAtStartWithDelay(self, other, delay) 2290 2291 def StaysInSync(self, other: "IntervalVar") -> "operations_research::Constraint *": 2292 return _pywrapcp.IntervalVar_StaysInSync(self, other) 2293 2294 def StaysInSyncWithDelay(self, other: "IntervalVar", delay: "int64_t") -> "operations_research::Constraint *": 2295 return _pywrapcp.IntervalVar_StaysInSyncWithDelay(self, other, delay) 2296 2297 def EndsAfter(self, date: "int64_t") -> "operations_research::Constraint *": 2298 return _pywrapcp.IntervalVar_EndsAfter(self, date) 2299 2300 def EndsAt(self, date: "int64_t") -> "operations_research::Constraint *": 2301 return _pywrapcp.IntervalVar_EndsAt(self, date) 2302 2303 def EndsBefore(self, date: "int64_t") -> "operations_research::Constraint *": 2304 return _pywrapcp.IntervalVar_EndsBefore(self, date) 2305 2306 def StartsAfter(self, date: "int64_t") -> "operations_research::Constraint *": 2307 return _pywrapcp.IntervalVar_StartsAfter(self, date) 2308 2309 def StartsAt(self, date: "int64_t") -> "operations_research::Constraint *": 2310 return _pywrapcp.IntervalVar_StartsAt(self, date) 2311 2312 def StartsBefore(self, date: "int64_t") -> "operations_research::Constraint *": 2313 return _pywrapcp.IntervalVar_StartsBefore(self, date) 2314 2315 def CrossesDate(self, date: "int64_t") -> "operations_research::Constraint *": 2316 return _pywrapcp.IntervalVar_CrossesDate(self, date) 2317 2318 def AvoidsDate(self, date: "int64_t") -> "operations_research::Constraint *": 2319 return _pywrapcp.IntervalVar_AvoidsDate(self, date) 2320 2321 def __repr__(self) -> "std::string": 2322 return _pywrapcp.IntervalVar___repr__(self) 2323 2324 def __str__(self) -> "std::string": 2325 return _pywrapcp.IntervalVar___str__(self)
Interval variables are often used in scheduling. The main characteristics of an IntervalVar are the start position, duration, and end date. All these characteristics can be queried and set, and demons can be posted on their modifications. An important aspect is optionality: an IntervalVar can be performed or not. If unperformed, then it simply does not exist, and its characteristics cannot be accessed any more. An interval var is automatically marked as unperformed when it is not consistent anymore (start greater than end, duration < 0...)
2102 def StartMin(self) -> "int64_t": 2103 r""" These methods query, set, and watch the start position of the interval var.""" 2104 return _pywrapcp.IntervalVar_StartMin(self)
These methods query, set, and watch the start position of the interval var.
2130 def DurationMin(self) -> "int64_t": 2131 r""" These methods query, set, and watch the duration of the interval var.""" 2132 return _pywrapcp.IntervalVar_DurationMin(self)
These methods query, set, and watch the duration of the interval var.
2158 def EndMin(self) -> "int64_t": 2159 r""" These methods query, set, and watch the end position of the interval var.""" 2160 return _pywrapcp.IntervalVar_EndMin(self)
These methods query, set, and watch the end position of the interval var.
2186 def MustBePerformed(self) -> "bool": 2187 r""" These methods query, set, and watch the performed status of the interval var.""" 2188 return _pywrapcp.IntervalVar_MustBePerformed(self)
These methods query, set, and watch the performed status of the interval var.
2208 def WhenAnything(self, *args) -> "void": 2209 r""" 2210 *Overload 1:* 2211 Attaches a demon awakened when anything about this interval changes. 2212 2213 | 2214 2215 *Overload 2:* 2216 Attaches a closure awakened when anything about this interval changes. 2217 """ 2218 return _pywrapcp.IntervalVar_WhenAnything(self, *args)
Overload 1: Attaches a demon awakened when anything about this interval changes.
|
Overload 2: Attaches a closure awakened when anything about this interval changes.
2220 def StartExpr(self) -> "operations_research::IntExpr *": 2221 r""" These methods create expressions encapsulating the start, end and duration of the interval var. Please note that these must not be used if the interval var is unperformed.""" 2222 return _pywrapcp.IntervalVar_StartExpr(self)
These methods create expressions encapsulating the start, end and duration of the interval var. Please note that these must not be used if the interval var is unperformed.
2233 def SafeStartExpr(self, unperformed_value: "int64_t") -> "operations_research::IntExpr *": 2234 r""" These methods create expressions encapsulating the start, end and duration of the interval var. If the interval var is unperformed, they will return the unperformed_value.""" 2235 return _pywrapcp.IntervalVar_SafeStartExpr(self, unperformed_value)
These methods create expressions encapsulating the start, end and duration of the interval var. If the interval var is unperformed, they will return the unperformed_value.
Inherited Members
2330class SequenceVar(PropagationBaseObject): 2331 r""" A sequence variable is a variable whose domain is a set of possible orderings of the interval variables. It allows ordering of tasks. It has two sets of methods: ComputePossibleFirstsAndLasts(), which returns the list of interval variables that can be ranked first or last; and RankFirst/RankNotFirst/RankLast/RankNotLast, which can be used to create the search decision.""" 2332 2333 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2334 2335 def __init__(self, *args, **kwargs): 2336 raise AttributeError("No constructor defined") 2337 2338 def DebugString(self) -> "std::string": 2339 return _pywrapcp.SequenceVar_DebugString(self) 2340 2341 def RankFirst(self, index: "int") -> "void": 2342 r""" Ranks the index_th interval var first of all unranked interval vars. After that, it will no longer be considered ranked.""" 2343 return _pywrapcp.SequenceVar_RankFirst(self, index) 2344 2345 def RankNotFirst(self, index: "int") -> "void": 2346 r""" Indicates that the index_th interval var will not be ranked first of all currently unranked interval vars.""" 2347 return _pywrapcp.SequenceVar_RankNotFirst(self, index) 2348 2349 def RankLast(self, index: "int") -> "void": 2350 r""" Ranks the index_th interval var first of all unranked interval vars. After that, it will no longer be considered ranked.""" 2351 return _pywrapcp.SequenceVar_RankLast(self, index) 2352 2353 def RankNotLast(self, index: "int") -> "void": 2354 r""" Indicates that the index_th interval var will not be ranked first of all currently unranked interval vars.""" 2355 return _pywrapcp.SequenceVar_RankNotLast(self, index) 2356 2357 def Interval(self, index: "int") -> "operations_research::IntervalVar *": 2358 r""" Returns the index_th interval of the sequence.""" 2359 return _pywrapcp.SequenceVar_Interval(self, index) 2360 2361 def Next(self, index: "int") -> "operations_research::IntVar *": 2362 r""" Returns the next of the index_th interval of the sequence.""" 2363 return _pywrapcp.SequenceVar_Next(self, index) 2364 2365 def Size(self) -> "int64_t": 2366 r""" Returns the number of interval vars in the sequence.""" 2367 return _pywrapcp.SequenceVar_Size(self) 2368 2369 def __repr__(self) -> "std::string": 2370 return _pywrapcp.SequenceVar___repr__(self) 2371 2372 def __str__(self) -> "std::string": 2373 return _pywrapcp.SequenceVar___str__(self)
A sequence variable is a variable whose domain is a set of possible orderings of the interval variables. It allows ordering of tasks. It has two sets of methods: ComputePossibleFirstsAndLasts(), which returns the list of interval variables that can be ranked first or last; and RankFirst/RankNotFirst/RankLast/RankNotLast, which can be used to create the search decision.
2341 def RankFirst(self, index: "int") -> "void": 2342 r""" Ranks the index_th interval var first of all unranked interval vars. After that, it will no longer be considered ranked.""" 2343 return _pywrapcp.SequenceVar_RankFirst(self, index)
Ranks the index_th interval var first of all unranked interval vars. After that, it will no longer be considered ranked.
2345 def RankNotFirst(self, index: "int") -> "void": 2346 r""" Indicates that the index_th interval var will not be ranked first of all currently unranked interval vars.""" 2347 return _pywrapcp.SequenceVar_RankNotFirst(self, index)
Indicates that the index_th interval var will not be ranked first of all currently unranked interval vars.
2349 def RankLast(self, index: "int") -> "void": 2350 r""" Ranks the index_th interval var first of all unranked interval vars. After that, it will no longer be considered ranked.""" 2351 return _pywrapcp.SequenceVar_RankLast(self, index)
Ranks the index_th interval var first of all unranked interval vars. After that, it will no longer be considered ranked.
2353 def RankNotLast(self, index: "int") -> "void": 2354 r""" Indicates that the index_th interval var will not be ranked first of all currently unranked interval vars.""" 2355 return _pywrapcp.SequenceVar_RankNotLast(self, index)
Indicates that the index_th interval var will not be ranked first of all currently unranked interval vars.
2357 def Interval(self, index: "int") -> "operations_research::IntervalVar *": 2358 r""" Returns the index_th interval of the sequence.""" 2359 return _pywrapcp.SequenceVar_Interval(self, index)
Returns the index_th interval of the sequence.
2361 def Next(self, index: "int") -> "operations_research::IntVar *": 2362 r""" Returns the next of the index_th interval of the sequence.""" 2363 return _pywrapcp.SequenceVar_Next(self, index)
Returns the next of the index_th interval of the sequence.
2365 def Size(self) -> "int64_t": 2366 r""" Returns the number of interval vars in the sequence.""" 2367 return _pywrapcp.SequenceVar_Size(self)
Returns the number of interval vars in the sequence.
Inherited Members
2378class AssignmentElement(object): 2379 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2380 2381 def __init__(self, *args, **kwargs): 2382 raise AttributeError("No constructor defined") 2383 __repr__ = _swig_repr 2384 2385 def Activate(self) -> "void": 2386 return _pywrapcp.AssignmentElement_Activate(self) 2387 2388 def Deactivate(self) -> "void": 2389 return _pywrapcp.AssignmentElement_Deactivate(self) 2390 2391 def Activated(self) -> "bool": 2392 return _pywrapcp.AssignmentElement_Activated(self) 2393 __swig_destroy__ = _pywrapcp.delete_AssignmentElement
2398class IntVarElement(AssignmentElement): 2399 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2400 2401 def __init__(self, *args, **kwargs): 2402 raise AttributeError("No constructor defined") 2403 __repr__ = _swig_repr 2404 2405 def Var(self) -> "operations_research::IntVar *": 2406 return _pywrapcp.IntVarElement_Var(self) 2407 2408 def Min(self) -> "int64_t": 2409 return _pywrapcp.IntVarElement_Min(self) 2410 2411 def SetMin(self, m: "int64_t") -> "void": 2412 return _pywrapcp.IntVarElement_SetMin(self, m) 2413 2414 def Max(self) -> "int64_t": 2415 return _pywrapcp.IntVarElement_Max(self) 2416 2417 def SetMax(self, m: "int64_t") -> "void": 2418 return _pywrapcp.IntVarElement_SetMax(self, m) 2419 2420 def Value(self) -> "int64_t": 2421 return _pywrapcp.IntVarElement_Value(self) 2422 2423 def Bound(self) -> "bool": 2424 return _pywrapcp.IntVarElement_Bound(self) 2425 2426 def SetRange(self, l: "int64_t", u: "int64_t") -> "void": 2427 return _pywrapcp.IntVarElement_SetRange(self, l, u) 2428 2429 def SetValue(self, v: "int64_t") -> "void": 2430 return _pywrapcp.IntVarElement_SetValue(self, v) 2431 2432 def __eq__(self, element: "IntVarElement") -> "bool": 2433 return _pywrapcp.IntVarElement___eq__(self, element) 2434 2435 def __ne__(self, element: "IntVarElement") -> "bool": 2436 return _pywrapcp.IntVarElement___ne__(self, element) 2437 __swig_destroy__ = _pywrapcp.delete_IntVarElement
Inherited Members
2442class IntervalVarElement(AssignmentElement): 2443 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2444 2445 def __init__(self, *args, **kwargs): 2446 raise AttributeError("No constructor defined") 2447 __repr__ = _swig_repr 2448 2449 def Var(self) -> "operations_research::IntervalVar *": 2450 return _pywrapcp.IntervalVarElement_Var(self) 2451 2452 def StartMin(self) -> "int64_t": 2453 return _pywrapcp.IntervalVarElement_StartMin(self) 2454 2455 def StartMax(self) -> "int64_t": 2456 return _pywrapcp.IntervalVarElement_StartMax(self) 2457 2458 def StartValue(self) -> "int64_t": 2459 return _pywrapcp.IntervalVarElement_StartValue(self) 2460 2461 def DurationMin(self) -> "int64_t": 2462 return _pywrapcp.IntervalVarElement_DurationMin(self) 2463 2464 def DurationMax(self) -> "int64_t": 2465 return _pywrapcp.IntervalVarElement_DurationMax(self) 2466 2467 def DurationValue(self) -> "int64_t": 2468 return _pywrapcp.IntervalVarElement_DurationValue(self) 2469 2470 def EndMin(self) -> "int64_t": 2471 return _pywrapcp.IntervalVarElement_EndMin(self) 2472 2473 def EndMax(self) -> "int64_t": 2474 return _pywrapcp.IntervalVarElement_EndMax(self) 2475 2476 def EndValue(self) -> "int64_t": 2477 return _pywrapcp.IntervalVarElement_EndValue(self) 2478 2479 def PerformedMin(self) -> "int64_t": 2480 return _pywrapcp.IntervalVarElement_PerformedMin(self) 2481 2482 def PerformedMax(self) -> "int64_t": 2483 return _pywrapcp.IntervalVarElement_PerformedMax(self) 2484 2485 def PerformedValue(self) -> "int64_t": 2486 return _pywrapcp.IntervalVarElement_PerformedValue(self) 2487 2488 def SetStartMin(self, m: "int64_t") -> "void": 2489 return _pywrapcp.IntervalVarElement_SetStartMin(self, m) 2490 2491 def SetStartMax(self, m: "int64_t") -> "void": 2492 return _pywrapcp.IntervalVarElement_SetStartMax(self, m) 2493 2494 def SetStartRange(self, mi: "int64_t", ma: "int64_t") -> "void": 2495 return _pywrapcp.IntervalVarElement_SetStartRange(self, mi, ma) 2496 2497 def SetStartValue(self, v: "int64_t") -> "void": 2498 return _pywrapcp.IntervalVarElement_SetStartValue(self, v) 2499 2500 def SetDurationMin(self, m: "int64_t") -> "void": 2501 return _pywrapcp.IntervalVarElement_SetDurationMin(self, m) 2502 2503 def SetDurationMax(self, m: "int64_t") -> "void": 2504 return _pywrapcp.IntervalVarElement_SetDurationMax(self, m) 2505 2506 def SetDurationRange(self, mi: "int64_t", ma: "int64_t") -> "void": 2507 return _pywrapcp.IntervalVarElement_SetDurationRange(self, mi, ma) 2508 2509 def SetDurationValue(self, v: "int64_t") -> "void": 2510 return _pywrapcp.IntervalVarElement_SetDurationValue(self, v) 2511 2512 def SetEndMin(self, m: "int64_t") -> "void": 2513 return _pywrapcp.IntervalVarElement_SetEndMin(self, m) 2514 2515 def SetEndMax(self, m: "int64_t") -> "void": 2516 return _pywrapcp.IntervalVarElement_SetEndMax(self, m) 2517 2518 def SetEndRange(self, mi: "int64_t", ma: "int64_t") -> "void": 2519 return _pywrapcp.IntervalVarElement_SetEndRange(self, mi, ma) 2520 2521 def SetEndValue(self, v: "int64_t") -> "void": 2522 return _pywrapcp.IntervalVarElement_SetEndValue(self, v) 2523 2524 def SetPerformedMin(self, m: "int64_t") -> "void": 2525 return _pywrapcp.IntervalVarElement_SetPerformedMin(self, m) 2526 2527 def SetPerformedMax(self, m: "int64_t") -> "void": 2528 return _pywrapcp.IntervalVarElement_SetPerformedMax(self, m) 2529 2530 def SetPerformedRange(self, mi: "int64_t", ma: "int64_t") -> "void": 2531 return _pywrapcp.IntervalVarElement_SetPerformedRange(self, mi, ma) 2532 2533 def SetPerformedValue(self, v: "int64_t") -> "void": 2534 return _pywrapcp.IntervalVarElement_SetPerformedValue(self, v) 2535 2536 def __eq__(self, element: "IntervalVarElement") -> "bool": 2537 return _pywrapcp.IntervalVarElement___eq__(self, element) 2538 2539 def __ne__(self, element: "IntervalVarElement") -> "bool": 2540 return _pywrapcp.IntervalVarElement___ne__(self, element) 2541 __swig_destroy__ = _pywrapcp.delete_IntervalVarElement
Inherited Members
2546class SequenceVarElement(AssignmentElement): 2547 r""" The SequenceVarElement stores a partial representation of ranked interval variables in the underlying sequence variable. This representation consists of three vectors: - the forward sequence. That is the list of interval variables ranked first in the sequence. The first element of the backward sequence is the first interval in the sequence variable. - the backward sequence. That is the list of interval variables ranked last in the sequence. The first element of the backward sequence is the last interval in the sequence variable. - The list of unperformed interval variables. Furthermore, if all performed variables are ranked, then by convention, the forward_sequence will contain all such variables and the backward_sequence will be empty.""" 2548 2549 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2550 2551 def __init__(self, *args, **kwargs): 2552 raise AttributeError("No constructor defined") 2553 __repr__ = _swig_repr 2554 2555 def Var(self) -> "operations_research::SequenceVar *": 2556 return _pywrapcp.SequenceVarElement_Var(self) 2557 2558 def ForwardSequence(self) -> "std::vector< int > const &": 2559 return _pywrapcp.SequenceVarElement_ForwardSequence(self) 2560 2561 def BackwardSequence(self) -> "std::vector< int > const &": 2562 return _pywrapcp.SequenceVarElement_BackwardSequence(self) 2563 2564 def Unperformed(self) -> "std::vector< int > const &": 2565 return _pywrapcp.SequenceVarElement_Unperformed(self) 2566 2567 def SetSequence(self, forward_sequence: "std::vector< int > const &", backward_sequence: "std::vector< int > const &", unperformed: "std::vector< int > const &") -> "void": 2568 return _pywrapcp.SequenceVarElement_SetSequence(self, forward_sequence, backward_sequence, unperformed) 2569 2570 def SetForwardSequence(self, forward_sequence: "std::vector< int > const &") -> "void": 2571 return _pywrapcp.SequenceVarElement_SetForwardSequence(self, forward_sequence) 2572 2573 def SetBackwardSequence(self, backward_sequence: "std::vector< int > const &") -> "void": 2574 return _pywrapcp.SequenceVarElement_SetBackwardSequence(self, backward_sequence) 2575 2576 def SetUnperformed(self, unperformed: "std::vector< int > const &") -> "void": 2577 return _pywrapcp.SequenceVarElement_SetUnperformed(self, unperformed) 2578 2579 def __eq__(self, element: "SequenceVarElement") -> "bool": 2580 return _pywrapcp.SequenceVarElement___eq__(self, element) 2581 2582 def __ne__(self, element: "SequenceVarElement") -> "bool": 2583 return _pywrapcp.SequenceVarElement___ne__(self, element) 2584 __swig_destroy__ = _pywrapcp.delete_SequenceVarElement
The SequenceVarElement stores a partial representation of ranked interval variables in the underlying sequence variable. This representation consists of three vectors: - the forward sequence. That is the list of interval variables ranked first in the sequence. The first element of the backward sequence is the first interval in the sequence variable. - the backward sequence. That is the list of interval variables ranked last in the sequence. The first element of the backward sequence is the last interval in the sequence variable. - The list of unperformed interval variables. Furthermore, if all performed variables are ranked, then by convention, the forward_sequence will contain all such variables and the backward_sequence will be empty.
Inherited Members
2589class Assignment(PropagationBaseObject): 2590 r""" An Assignment is a variable -> domains mapping, used to report solutions to the user.""" 2591 2592 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2593 2594 def __init__(self, *args, **kwargs): 2595 raise AttributeError("No constructor defined") 2596 __repr__ = _swig_repr 2597 2598 def Clear(self) -> "void": 2599 return _pywrapcp.Assignment_Clear(self) 2600 2601 def Empty(self) -> "bool": 2602 return _pywrapcp.Assignment_Empty(self) 2603 2604 def Size(self) -> "int": 2605 return _pywrapcp.Assignment_Size(self) 2606 2607 def NumIntVars(self) -> "int": 2608 return _pywrapcp.Assignment_NumIntVars(self) 2609 2610 def NumIntervalVars(self) -> "int": 2611 return _pywrapcp.Assignment_NumIntervalVars(self) 2612 2613 def NumSequenceVars(self) -> "int": 2614 return _pywrapcp.Assignment_NumSequenceVars(self) 2615 2616 def Store(self) -> "void": 2617 return _pywrapcp.Assignment_Store(self) 2618 2619 def Restore(self) -> "void": 2620 return _pywrapcp.Assignment_Restore(self) 2621 2622 def Load(self, *args) -> "void": 2623 return _pywrapcp.Assignment_Load(self, *args) 2624 2625 def Save(self, *args) -> "void": 2626 return _pywrapcp.Assignment_Save(self, *args) 2627 2628 def AddObjective(self, v: "IntVar") -> "void": 2629 return _pywrapcp.Assignment_AddObjective(self, v) 2630 2631 def Objective(self) -> "operations_research::IntVar *": 2632 return _pywrapcp.Assignment_Objective(self) 2633 2634 def HasObjective(self) -> "bool": 2635 return _pywrapcp.Assignment_HasObjective(self) 2636 2637 def ObjectiveMin(self) -> "int64_t": 2638 return _pywrapcp.Assignment_ObjectiveMin(self) 2639 2640 def ObjectiveMax(self) -> "int64_t": 2641 return _pywrapcp.Assignment_ObjectiveMax(self) 2642 2643 def ObjectiveValue(self) -> "int64_t": 2644 return _pywrapcp.Assignment_ObjectiveValue(self) 2645 2646 def ObjectiveBound(self) -> "bool": 2647 return _pywrapcp.Assignment_ObjectiveBound(self) 2648 2649 def SetObjectiveMin(self, m: "int64_t") -> "void": 2650 return _pywrapcp.Assignment_SetObjectiveMin(self, m) 2651 2652 def SetObjectiveMax(self, m: "int64_t") -> "void": 2653 return _pywrapcp.Assignment_SetObjectiveMax(self, m) 2654 2655 def SetObjectiveValue(self, value: "int64_t") -> "void": 2656 return _pywrapcp.Assignment_SetObjectiveValue(self, value) 2657 2658 def SetObjectiveRange(self, l: "int64_t", u: "int64_t") -> "void": 2659 return _pywrapcp.Assignment_SetObjectiveRange(self, l, u) 2660 2661 def Min(self, var: "IntVar") -> "int64_t": 2662 return _pywrapcp.Assignment_Min(self, var) 2663 2664 def Max(self, var: "IntVar") -> "int64_t": 2665 return _pywrapcp.Assignment_Max(self, var) 2666 2667 def Value(self, var: "IntVar") -> "int64_t": 2668 return _pywrapcp.Assignment_Value(self, var) 2669 2670 def Bound(self, var: "IntVar") -> "bool": 2671 return _pywrapcp.Assignment_Bound(self, var) 2672 2673 def SetMin(self, var: "IntVar", m: "int64_t") -> "void": 2674 return _pywrapcp.Assignment_SetMin(self, var, m) 2675 2676 def SetMax(self, var: "IntVar", m: "int64_t") -> "void": 2677 return _pywrapcp.Assignment_SetMax(self, var, m) 2678 2679 def SetRange(self, var: "IntVar", l: "int64_t", u: "int64_t") -> "void": 2680 return _pywrapcp.Assignment_SetRange(self, var, l, u) 2681 2682 def SetValue(self, var: "IntVar", value: "int64_t") -> "void": 2683 return _pywrapcp.Assignment_SetValue(self, var, value) 2684 2685 def StartMin(self, var: "IntervalVar") -> "int64_t": 2686 return _pywrapcp.Assignment_StartMin(self, var) 2687 2688 def StartMax(self, var: "IntervalVar") -> "int64_t": 2689 return _pywrapcp.Assignment_StartMax(self, var) 2690 2691 def StartValue(self, var: "IntervalVar") -> "int64_t": 2692 return _pywrapcp.Assignment_StartValue(self, var) 2693 2694 def DurationMin(self, var: "IntervalVar") -> "int64_t": 2695 return _pywrapcp.Assignment_DurationMin(self, var) 2696 2697 def DurationMax(self, var: "IntervalVar") -> "int64_t": 2698 return _pywrapcp.Assignment_DurationMax(self, var) 2699 2700 def DurationValue(self, var: "IntervalVar") -> "int64_t": 2701 return _pywrapcp.Assignment_DurationValue(self, var) 2702 2703 def EndMin(self, var: "IntervalVar") -> "int64_t": 2704 return _pywrapcp.Assignment_EndMin(self, var) 2705 2706 def EndMax(self, var: "IntervalVar") -> "int64_t": 2707 return _pywrapcp.Assignment_EndMax(self, var) 2708 2709 def EndValue(self, var: "IntervalVar") -> "int64_t": 2710 return _pywrapcp.Assignment_EndValue(self, var) 2711 2712 def PerformedMin(self, var: "IntervalVar") -> "int64_t": 2713 return _pywrapcp.Assignment_PerformedMin(self, var) 2714 2715 def PerformedMax(self, var: "IntervalVar") -> "int64_t": 2716 return _pywrapcp.Assignment_PerformedMax(self, var) 2717 2718 def PerformedValue(self, var: "IntervalVar") -> "int64_t": 2719 return _pywrapcp.Assignment_PerformedValue(self, var) 2720 2721 def SetStartMin(self, var: "IntervalVar", m: "int64_t") -> "void": 2722 return _pywrapcp.Assignment_SetStartMin(self, var, m) 2723 2724 def SetStartMax(self, var: "IntervalVar", m: "int64_t") -> "void": 2725 return _pywrapcp.Assignment_SetStartMax(self, var, m) 2726 2727 def SetStartRange(self, var: "IntervalVar", mi: "int64_t", ma: "int64_t") -> "void": 2728 return _pywrapcp.Assignment_SetStartRange(self, var, mi, ma) 2729 2730 def SetStartValue(self, var: "IntervalVar", value: "int64_t") -> "void": 2731 return _pywrapcp.Assignment_SetStartValue(self, var, value) 2732 2733 def SetDurationMin(self, var: "IntervalVar", m: "int64_t") -> "void": 2734 return _pywrapcp.Assignment_SetDurationMin(self, var, m) 2735 2736 def SetDurationMax(self, var: "IntervalVar", m: "int64_t") -> "void": 2737 return _pywrapcp.Assignment_SetDurationMax(self, var, m) 2738 2739 def SetDurationRange(self, var: "IntervalVar", mi: "int64_t", ma: "int64_t") -> "void": 2740 return _pywrapcp.Assignment_SetDurationRange(self, var, mi, ma) 2741 2742 def SetDurationValue(self, var: "IntervalVar", value: "int64_t") -> "void": 2743 return _pywrapcp.Assignment_SetDurationValue(self, var, value) 2744 2745 def SetEndMin(self, var: "IntervalVar", m: "int64_t") -> "void": 2746 return _pywrapcp.Assignment_SetEndMin(self, var, m) 2747 2748 def SetEndMax(self, var: "IntervalVar", m: "int64_t") -> "void": 2749 return _pywrapcp.Assignment_SetEndMax(self, var, m) 2750 2751 def SetEndRange(self, var: "IntervalVar", mi: "int64_t", ma: "int64_t") -> "void": 2752 return _pywrapcp.Assignment_SetEndRange(self, var, mi, ma) 2753 2754 def SetEndValue(self, var: "IntervalVar", value: "int64_t") -> "void": 2755 return _pywrapcp.Assignment_SetEndValue(self, var, value) 2756 2757 def SetPerformedMin(self, var: "IntervalVar", m: "int64_t") -> "void": 2758 return _pywrapcp.Assignment_SetPerformedMin(self, var, m) 2759 2760 def SetPerformedMax(self, var: "IntervalVar", m: "int64_t") -> "void": 2761 return _pywrapcp.Assignment_SetPerformedMax(self, var, m) 2762 2763 def SetPerformedRange(self, var: "IntervalVar", mi: "int64_t", ma: "int64_t") -> "void": 2764 return _pywrapcp.Assignment_SetPerformedRange(self, var, mi, ma) 2765 2766 def SetPerformedValue(self, var: "IntervalVar", value: "int64_t") -> "void": 2767 return _pywrapcp.Assignment_SetPerformedValue(self, var, value) 2768 2769 def Add(self, *args) -> "void": 2770 return _pywrapcp.Assignment_Add(self, *args) 2771 2772 def ForwardSequence(self, var: "SequenceVar") -> "std::vector< int > const &": 2773 return _pywrapcp.Assignment_ForwardSequence(self, var) 2774 2775 def BackwardSequence(self, var: "SequenceVar") -> "std::vector< int > const &": 2776 return _pywrapcp.Assignment_BackwardSequence(self, var) 2777 2778 def Unperformed(self, var: "SequenceVar") -> "std::vector< int > const &": 2779 return _pywrapcp.Assignment_Unperformed(self, var) 2780 2781 def SetSequence(self, var: "SequenceVar", forward_sequence: "std::vector< int > const &", backward_sequence: "std::vector< int > const &", unperformed: "std::vector< int > const &") -> "void": 2782 return _pywrapcp.Assignment_SetSequence(self, var, forward_sequence, backward_sequence, unperformed) 2783 2784 def SetForwardSequence(self, var: "SequenceVar", forward_sequence: "std::vector< int > const &") -> "void": 2785 return _pywrapcp.Assignment_SetForwardSequence(self, var, forward_sequence) 2786 2787 def SetBackwardSequence(self, var: "SequenceVar", backward_sequence: "std::vector< int > const &") -> "void": 2788 return _pywrapcp.Assignment_SetBackwardSequence(self, var, backward_sequence) 2789 2790 def SetUnperformed(self, var: "SequenceVar", unperformed: "std::vector< int > const &") -> "void": 2791 return _pywrapcp.Assignment_SetUnperformed(self, var, unperformed) 2792 2793 def Activate(self, *args) -> "void": 2794 return _pywrapcp.Assignment_Activate(self, *args) 2795 2796 def Deactivate(self, *args) -> "void": 2797 return _pywrapcp.Assignment_Deactivate(self, *args) 2798 2799 def Activated(self, *args) -> "bool": 2800 return _pywrapcp.Assignment_Activated(self, *args) 2801 2802 def DebugString(self) -> "std::string": 2803 return _pywrapcp.Assignment_DebugString(self) 2804 2805 def IntVarContainer(self) -> "operations_research::Assignment::IntContainer const &": 2806 return _pywrapcp.Assignment_IntVarContainer(self) 2807 2808 def MutableIntVarContainer(self) -> "operations_research::Assignment::IntContainer *": 2809 return _pywrapcp.Assignment_MutableIntVarContainer(self) 2810 2811 def IntervalVarContainer(self) -> "operations_research::Assignment::IntervalContainer const &": 2812 return _pywrapcp.Assignment_IntervalVarContainer(self) 2813 2814 def MutableIntervalVarContainer(self) -> "operations_research::Assignment::IntervalContainer *": 2815 return _pywrapcp.Assignment_MutableIntervalVarContainer(self) 2816 2817 def SequenceVarContainer(self) -> "operations_research::Assignment::SequenceContainer const &": 2818 return _pywrapcp.Assignment_SequenceVarContainer(self) 2819 2820 def MutableSequenceVarContainer(self) -> "operations_research::Assignment::SequenceContainer *": 2821 return _pywrapcp.Assignment_MutableSequenceVarContainer(self) 2822 2823 def __eq__(self, assignment: "Assignment") -> "bool": 2824 return _pywrapcp.Assignment___eq__(self, assignment) 2825 2826 def __ne__(self, assignment: "Assignment") -> "bool": 2827 return _pywrapcp.Assignment___ne__(self, assignment)
An Assignment is a variable -> domains mapping, used to report solutions to the user.
2781 def SetSequence(self, var: "SequenceVar", forward_sequence: "std::vector< int > const &", backward_sequence: "std::vector< int > const &", unperformed: "std::vector< int > const &") -> "void": 2782 return _pywrapcp.Assignment_SetSequence(self, var, forward_sequence, backward_sequence, unperformed)
Inherited Members
2835class Pack(Constraint): 2836 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2837 2838 def __init__(self, *args, **kwargs): 2839 raise AttributeError("No constructor defined") 2840 __repr__ = _swig_repr 2841 2842 def AddWeightedSumLessOrEqualConstantDimension(self, *args) -> "void": 2843 r""" 2844 *Overload 1:* 2845 Dimensions are additional constraints than can restrict what is possible with the pack constraint. It can be used to set capacity limits, to count objects per bin, to compute unassigned penalties... This dimension imposes that for all bins b, the weighted sum (weights[i]) of all objects i assigned to 'b' is less or equal 'bounds[b]'. 2846 2847 | 2848 2849 *Overload 2:* 2850 This dimension imposes that for all bins b, the weighted sum (weights->Run(i)) of all objects i assigned to 'b' is less or equal to 'bounds[b]'. Ownership of the callback is transferred to the pack constraint. 2851 2852 | 2853 2854 *Overload 3:* 2855 This dimension imposes that for all bins b, the weighted sum (weights->Run(i, b) of all objects i assigned to 'b' is less or equal to 'bounds[b]'. Ownership of the callback is transferred to the pack constraint. 2856 """ 2857 return _pywrapcp.Pack_AddWeightedSumLessOrEqualConstantDimension(self, *args) 2858 2859 def AddWeightedSumEqualVarDimension(self, *args) -> "void": 2860 r""" 2861 *Overload 1:* 2862 This dimension imposes that for all bins b, the weighted sum (weights[i]) of all objects i assigned to 'b' is equal to loads[b]. 2863 2864 | 2865 2866 *Overload 2:* 2867 This dimension imposes that for all bins b, the weighted sum (weights->Run(i, b)) of all objects i assigned to 'b' is equal to loads[b]. 2868 """ 2869 return _pywrapcp.Pack_AddWeightedSumEqualVarDimension(self, *args) 2870 2871 def AddSumVariableWeightsLessOrEqualConstantDimension(self, usage: "std::vector< operations_research::IntVar * > const &", capacity: "std::vector< int64_t > const &") -> "void": 2872 r""" This dimension imposes: forall b in bins, sum (i in items: usage[i] * is_assigned(i, b)) <= capacity[b] where is_assigned(i, b) is true if and only if item i is assigned to the bin b. This can be used to model shapes of items by linking variables of the same item on parallel dimensions with an allowed assignment constraint.""" 2873 return _pywrapcp.Pack_AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity) 2874 2875 def AddWeightedSumOfAssignedDimension(self, weights: "std::vector< int64_t > const &", cost_var: "IntVar") -> "void": 2876 r""" This dimension enforces that cost_var == sum of weights[i] for all objects 'i' assigned to a bin.""" 2877 return _pywrapcp.Pack_AddWeightedSumOfAssignedDimension(self, weights, cost_var) 2878 2879 def AddCountUsedBinDimension(self, count_var: "IntVar") -> "void": 2880 r""" This dimension links 'count_var' to the actual number of bins used in the pack.""" 2881 return _pywrapcp.Pack_AddCountUsedBinDimension(self, count_var) 2882 2883 def AddCountAssignedItemsDimension(self, count_var: "IntVar") -> "void": 2884 r""" This dimension links 'count_var' to the actual number of items assigned to a bin in the pack.""" 2885 return _pywrapcp.Pack_AddCountAssignedItemsDimension(self, count_var) 2886 2887 def Post(self) -> "void": 2888 return _pywrapcp.Pack_Post(self) 2889 2890 def InitialPropagateWrapper(self) -> "void": 2891 return _pywrapcp.Pack_InitialPropagateWrapper(self) 2892 2893 def DebugString(self) -> "std::string": 2894 return _pywrapcp.Pack_DebugString(self)
A constraint is the main modeling object. It provides two methods: - Post() is responsible for creating the demons and attaching them to immediate demons(). - InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.
2842 def AddWeightedSumLessOrEqualConstantDimension(self, *args) -> "void": 2843 r""" 2844 *Overload 1:* 2845 Dimensions are additional constraints than can restrict what is possible with the pack constraint. It can be used to set capacity limits, to count objects per bin, to compute unassigned penalties... This dimension imposes that for all bins b, the weighted sum (weights[i]) of all objects i assigned to 'b' is less or equal 'bounds[b]'. 2846 2847 | 2848 2849 *Overload 2:* 2850 This dimension imposes that for all bins b, the weighted sum (weights->Run(i)) of all objects i assigned to 'b' is less or equal to 'bounds[b]'. Ownership of the callback is transferred to the pack constraint. 2851 2852 | 2853 2854 *Overload 3:* 2855 This dimension imposes that for all bins b, the weighted sum (weights->Run(i, b) of all objects i assigned to 'b' is less or equal to 'bounds[b]'. Ownership of the callback is transferred to the pack constraint. 2856 """ 2857 return _pywrapcp.Pack_AddWeightedSumLessOrEqualConstantDimension(self, *args)
Overload 1: Dimensions are additional constraints than can restrict what is possible with the pack constraint. It can be used to set capacity limits, to count objects per bin, to compute unassigned penalties... This dimension imposes that for all bins b, the weighted sum (weights[i]) of all objects i assigned to 'b' is less or equal 'bounds[b]'.
|
Overload 2: This dimension imposes that for all bins b, the weighted sum (weights->Run(i)) of all objects i assigned to 'b' is less or equal to 'bounds[b]'. Ownership of the callback is transferred to the pack constraint.
|
Overload 3: This dimension imposes that for all bins b, the weighted sum (weights->Run(i, b) of all objects i assigned to 'b' is less or equal to 'bounds[b]'. Ownership of the callback is transferred to the pack constraint.
2859 def AddWeightedSumEqualVarDimension(self, *args) -> "void": 2860 r""" 2861 *Overload 1:* 2862 This dimension imposes that for all bins b, the weighted sum (weights[i]) of all objects i assigned to 'b' is equal to loads[b]. 2863 2864 | 2865 2866 *Overload 2:* 2867 This dimension imposes that for all bins b, the weighted sum (weights->Run(i, b)) of all objects i assigned to 'b' is equal to loads[b]. 2868 """ 2869 return _pywrapcp.Pack_AddWeightedSumEqualVarDimension(self, *args)
Overload 1: This dimension imposes that for all bins b, the weighted sum (weights[i]) of all objects i assigned to 'b' is equal to loads[b].
|
Overload 2: This dimension imposes that for all bins b, the weighted sum (weights->Run(i, b)) of all objects i assigned to 'b' is equal to loads[b].
2871 def AddSumVariableWeightsLessOrEqualConstantDimension(self, usage: "std::vector< operations_research::IntVar * > const &", capacity: "std::vector< int64_t > const &") -> "void": 2872 r""" This dimension imposes: forall b in bins, sum (i in items: usage[i] * is_assigned(i, b)) <= capacity[b] where is_assigned(i, b) is true if and only if item i is assigned to the bin b. This can be used to model shapes of items by linking variables of the same item on parallel dimensions with an allowed assignment constraint.""" 2873 return _pywrapcp.Pack_AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity)
This dimension imposes: forall b in bins, sum (i in items: usage[i] * is_assigned(i, b)) <= capacity[b] where is_assigned(i, b) is true if and only if item i is assigned to the bin b. This can be used to model shapes of items by linking variables of the same item on parallel dimensions with an allowed assignment constraint.
2875 def AddWeightedSumOfAssignedDimension(self, weights: "std::vector< int64_t > const &", cost_var: "IntVar") -> "void": 2876 r""" This dimension enforces that cost_var == sum of weights[i] for all objects 'i' assigned to a bin.""" 2877 return _pywrapcp.Pack_AddWeightedSumOfAssignedDimension(self, weights, cost_var)
This dimension enforces that cost_var == sum of weights[i] for all objects 'i' assigned to a bin.
2879 def AddCountUsedBinDimension(self, count_var: "IntVar") -> "void": 2880 r""" This dimension links 'count_var' to the actual number of bins used in the pack.""" 2881 return _pywrapcp.Pack_AddCountUsedBinDimension(self, count_var)
This dimension links 'count_var' to the actual number of bins used in the pack.
2883 def AddCountAssignedItemsDimension(self, count_var: "IntVar") -> "void": 2884 r""" This dimension links 'count_var' to the actual number of items assigned to a bin in the pack.""" 2885 return _pywrapcp.Pack_AddCountAssignedItemsDimension(self, count_var)
This dimension links 'count_var' to the actual number of items assigned to a bin in the pack.
This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.
2890 def InitialPropagateWrapper(self) -> "void": 2891 return _pywrapcp.Pack_InitialPropagateWrapper(self)
This method performs the initial propagation of the constraint. It is called just after the post.
Inherited Members
2899class DisjunctiveConstraint(Constraint): 2900 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2901 2902 def __init__(self, *args, **kwargs): 2903 raise AttributeError("No constructor defined - class is abstract") 2904 __repr__ = _swig_repr 2905 2906 def SequenceVar(self) -> "operations_research::SequenceVar *": 2907 r""" Creates a sequence variable from the constraint.""" 2908 return _pywrapcp.DisjunctiveConstraint_SequenceVar(self) 2909 2910 def SetTransitionTime(self, transition_time: "operations_research::Solver::IndexEvaluator2") -> "void": 2911 r""" Add a transition time between intervals. It forces the distance between the end of interval a and start of interval b that follows it to be at least transition_time(a, b). This function must always return a positive or null value.""" 2912 return _pywrapcp.DisjunctiveConstraint_SetTransitionTime(self, transition_time) 2913 2914 def TransitionTime(self, before_index: "int", after_index: "int") -> "int64_t": 2915 return _pywrapcp.DisjunctiveConstraint_TransitionTime(self, before_index, after_index)
A constraint is the main modeling object. It provides two methods: - Post() is responsible for creating the demons and attaching them to immediate demons(). - InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.
2906 def SequenceVar(self) -> "operations_research::SequenceVar *": 2907 r""" Creates a sequence variable from the constraint.""" 2908 return _pywrapcp.DisjunctiveConstraint_SequenceVar(self)
Creates a sequence variable from the constraint.
2910 def SetTransitionTime(self, transition_time: "operations_research::Solver::IndexEvaluator2") -> "void": 2911 r""" Add a transition time between intervals. It forces the distance between the end of interval a and start of interval b that follows it to be at least transition_time(a, b). This function must always return a positive or null value.""" 2912 return _pywrapcp.DisjunctiveConstraint_SetTransitionTime(self, transition_time)
Add a transition time between intervals. It forces the distance between the end of interval a and start of interval b that follows it to be at least transition_time(a, b). This function must always return a positive or null value.
Inherited Members
2920class RevInteger(object): 2921 r""" This class adds reversibility to a POD type. It contains the stamp optimization. i.e. the SaveValue call is done only once per node of the search tree. Please note that actual stamps always starts at 1, thus an initial value of 0 will always trigger the first SaveValue.""" 2922 2923 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2924 __repr__ = _swig_repr 2925 2926 def __init__(self, val: "long const &"): 2927 _pywrapcp.RevInteger_swiginit(self, _pywrapcp.new_RevInteger(val)) 2928 2929 def Value(self) -> "long const &": 2930 return _pywrapcp.RevInteger_Value(self) 2931 2932 def SetValue(self, s: "Solver", val: "long const &") -> "void": 2933 return _pywrapcp.RevInteger_SetValue(self, s, val) 2934 __swig_destroy__ = _pywrapcp.delete_RevInteger
This class adds reversibility to a POD type. It contains the stamp optimization. i.e. the SaveValue call is done only once per node of the search tree. Please note that actual stamps always starts at 1, thus an initial value of 0 will always trigger the first SaveValue.
2939class NumericalRevInteger(RevInteger): 2940 r""" Subclass of Rev<T> which adds numerical operations.""" 2941 2942 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2943 __repr__ = _swig_repr 2944 2945 def __init__(self, val: "long const &"): 2946 _pywrapcp.NumericalRevInteger_swiginit(self, _pywrapcp.new_NumericalRevInteger(val)) 2947 2948 def Add(self, s: "Solver", to_add: "long const &") -> "void": 2949 return _pywrapcp.NumericalRevInteger_Add(self, s, to_add) 2950 2951 def Incr(self, s: "Solver") -> "void": 2952 return _pywrapcp.NumericalRevInteger_Incr(self, s) 2953 2954 def Decr(self, s: "Solver") -> "void": 2955 return _pywrapcp.NumericalRevInteger_Decr(self, s) 2956 __swig_destroy__ = _pywrapcp.delete_NumericalRevInteger
Subclass of Rev
Inherited Members
2961class RevBool(object): 2962 r""" This class adds reversibility to a POD type. It contains the stamp optimization. i.e. the SaveValue call is done only once per node of the search tree. Please note that actual stamps always starts at 1, thus an initial value of 0 will always trigger the first SaveValue.""" 2963 2964 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2965 __repr__ = _swig_repr 2966 2967 def __init__(self, val: "bool const &"): 2968 _pywrapcp.RevBool_swiginit(self, _pywrapcp.new_RevBool(val)) 2969 2970 def Value(self) -> "bool const &": 2971 return _pywrapcp.RevBool_Value(self) 2972 2973 def SetValue(self, s: "Solver", val: "bool const &") -> "void": 2974 return _pywrapcp.RevBool_SetValue(self, s, val) 2975 __swig_destroy__ = _pywrapcp.delete_RevBool
This class adds reversibility to a POD type. It contains the stamp optimization. i.e. the SaveValue call is done only once per node of the search tree. Please note that actual stamps always starts at 1, thus an initial value of 0 will always trigger the first SaveValue.
2980class IntVarContainer(object): 2981 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 2982 2983 def __init__(self, *args, **kwargs): 2984 raise AttributeError("No constructor defined") 2985 __repr__ = _swig_repr 2986 2987 def Contains(self, var: "IntVar") -> "bool": 2988 return _pywrapcp.IntVarContainer_Contains(self, var) 2989 2990 def Element(self, index: "int") -> "operations_research::IntVarElement *": 2991 return _pywrapcp.IntVarContainer_Element(self, index) 2992 2993 def Size(self) -> "int": 2994 return _pywrapcp.IntVarContainer_Size(self) 2995 2996 def Store(self) -> "void": 2997 return _pywrapcp.IntVarContainer_Store(self) 2998 2999 def Restore(self) -> "void": 3000 return _pywrapcp.IntVarContainer_Restore(self) 3001 3002 def __eq__(self, container: "IntVarContainer") -> "bool": 3003 r""" Returns true if this and 'container' both represent the same V* -> E map. Runs in linear time; requires that the == operator on the type E is well defined.""" 3004 return _pywrapcp.IntVarContainer___eq__(self, container) 3005 3006 def __ne__(self, container: "IntVarContainer") -> "bool": 3007 return _pywrapcp.IntVarContainer___ne__(self, container) 3008 __swig_destroy__ = _pywrapcp.delete_IntVarContainer
3013class IntervalVarContainer(object): 3014 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3015 3016 def __init__(self, *args, **kwargs): 3017 raise AttributeError("No constructor defined") 3018 __repr__ = _swig_repr 3019 3020 def Contains(self, var: "IntervalVar") -> "bool": 3021 return _pywrapcp.IntervalVarContainer_Contains(self, var) 3022 3023 def Element(self, index: "int") -> "operations_research::IntervalVarElement *": 3024 return _pywrapcp.IntervalVarContainer_Element(self, index) 3025 3026 def Size(self) -> "int": 3027 return _pywrapcp.IntervalVarContainer_Size(self) 3028 3029 def Store(self) -> "void": 3030 return _pywrapcp.IntervalVarContainer_Store(self) 3031 3032 def Restore(self) -> "void": 3033 return _pywrapcp.IntervalVarContainer_Restore(self) 3034 3035 def __eq__(self, container: "IntervalVarContainer") -> "bool": 3036 r""" Returns true if this and 'container' both represent the same V* -> E map. Runs in linear time; requires that the == operator on the type E is well defined.""" 3037 return _pywrapcp.IntervalVarContainer___eq__(self, container) 3038 3039 def __ne__(self, container: "IntervalVarContainer") -> "bool": 3040 return _pywrapcp.IntervalVarContainer___ne__(self, container) 3041 __swig_destroy__ = _pywrapcp.delete_IntervalVarContainer
3046class SequenceVarContainer(object): 3047 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3048 3049 def __init__(self, *args, **kwargs): 3050 raise AttributeError("No constructor defined") 3051 __repr__ = _swig_repr 3052 3053 def Contains(self, var: "SequenceVar") -> "bool": 3054 return _pywrapcp.SequenceVarContainer_Contains(self, var) 3055 3056 def Element(self, index: "int") -> "operations_research::SequenceVarElement *": 3057 return _pywrapcp.SequenceVarContainer_Element(self, index) 3058 3059 def Size(self) -> "int": 3060 return _pywrapcp.SequenceVarContainer_Size(self) 3061 3062 def Store(self) -> "void": 3063 return _pywrapcp.SequenceVarContainer_Store(self) 3064 3065 def Restore(self) -> "void": 3066 return _pywrapcp.SequenceVarContainer_Restore(self) 3067 3068 def __eq__(self, container: "SequenceVarContainer") -> "bool": 3069 r""" Returns true if this and 'container' both represent the same V* -> E map. Runs in linear time; requires that the == operator on the type E is well defined.""" 3070 return _pywrapcp.SequenceVarContainer___eq__(self, container) 3071 3072 def __ne__(self, container: "SequenceVarContainer") -> "bool": 3073 return _pywrapcp.SequenceVarContainer___ne__(self, container) 3074 __swig_destroy__ = _pywrapcp.delete_SequenceVarContainer
3079class LocalSearchOperator(BaseObject): 3080 r""" This class represent a reversible FIFO structure. The main difference w.r.t a standard FIFO structure is that a Solver is given as parameter to the modifiers such that the solver can store the backtrack information Iterator's traversing order should not be changed, as some algorithm depend on it to be consistent. It's main use is to store a list of demons in the various classes of variables. The base class for all local search operators. A local search operator is an object that defines the neighborhood of a solution. In other words, a neighborhood is the set of solutions which can be reached from a given solution using an operator. The behavior of the LocalSearchOperator class is similar to iterators. The operator is synchronized with an assignment (gives the current values of the variables); this is done in the Start() method. Then one can iterate over the neighbors using the MakeNextNeighbor method. This method returns an assignment which represents the incremental changes to the current solution. It also returns a second assignment representing the changes to the last solution defined by the neighborhood operator; this assignment is empty if the neighborhood operator cannot track this information.""" 3081 3082 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3083 3084 def __init__(self, *args, **kwargs): 3085 raise AttributeError("No constructor defined - class is abstract") 3086 __repr__ = _swig_repr 3087 3088 def NextNeighbor(self, delta: "Assignment", deltadelta: "Assignment") -> "bool": 3089 return _pywrapcp.LocalSearchOperator_NextNeighbor(self, delta, deltadelta) 3090 3091 def Start(self, assignment: "Assignment") -> "void": 3092 return _pywrapcp.LocalSearchOperator_Start(self, assignment) 3093 def __disown__(self): 3094 self.this.disown() 3095 _pywrapcp.disown_LocalSearchOperator(self) 3096 return weakref.proxy(self)
This class represent a reversible FIFO structure. The main difference w.r.t a standard FIFO structure is that a Solver is given as parameter to the modifiers such that the solver can store the backtrack information Iterator's traversing order should not be changed, as some algorithm depend on it to be consistent. It's main use is to store a list of demons in the various classes of variables. The base class for all local search operators. A local search operator is an object that defines the neighborhood of a solution. In other words, a neighborhood is the set of solutions which can be reached from a given solution using an operator. The behavior of the LocalSearchOperator class is similar to iterators. The operator is synchronized with an assignment (gives the current values of the variables); this is done in the Start() method. Then one can iterate over the neighbors using the MakeNextNeighbor method. This method returns an assignment which represents the incremental changes to the current solution. It also returns a second assignment representing the changes to the last solution defined by the neighborhood operator; this assignment is empty if the neighborhood operator cannot track this information.
Inherited Members
3101class IntVarLocalSearchOperatorTemplate(LocalSearchOperator): 3102 r""" Base operator class for operators manipulating variables.""" 3103 3104 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3105 3106 def __init__(self, *args, **kwargs): 3107 raise AttributeError("No constructor defined - class is abstract") 3108 __repr__ = _swig_repr 3109 3110 def Start(self, assignment: "Assignment") -> "void": 3111 r""" This method should not be overridden. Override OnStart() instead which is called before exiting this method.""" 3112 return _pywrapcp.IntVarLocalSearchOperatorTemplate_Start(self, assignment) 3113 3114 def IsIncremental(self) -> "bool": 3115 return _pywrapcp.IntVarLocalSearchOperatorTemplate_IsIncremental(self) 3116 3117 def Size(self) -> "int": 3118 return _pywrapcp.IntVarLocalSearchOperatorTemplate_Size(self) 3119 3120 def Value(self, index: "int64_t") -> "long const &": 3121 r""" Returns the value in the current assignment of the variable of given index.""" 3122 return _pywrapcp.IntVarLocalSearchOperatorTemplate_Value(self, index) 3123 3124 def OldValue(self, index: "int64_t") -> "long const &": 3125 return _pywrapcp.IntVarLocalSearchOperatorTemplate_OldValue(self, index) 3126 3127 def SetValue(self, index: "int64_t", value: "long const &") -> "void": 3128 return _pywrapcp.IntVarLocalSearchOperatorTemplate_SetValue(self, index, value) 3129 3130 def OnStart(self) -> "void": 3131 r""" Called by Start() after synchronizing the operator with the current assignment. Should be overridden instead of Start() to avoid calling VarLocalSearchOperator::Start explicitly.""" 3132 return _pywrapcp.IntVarLocalSearchOperatorTemplate_OnStart(self)
Base operator class for operators manipulating variables.
3110 def Start(self, assignment: "Assignment") -> "void": 3111 r""" This method should not be overridden. Override OnStart() instead which is called before exiting this method.""" 3112 return _pywrapcp.IntVarLocalSearchOperatorTemplate_Start(self, assignment)
This method should not be overridden. Override OnStart() instead which is called before exiting this method.
3120 def Value(self, index: "int64_t") -> "long const &": 3121 r""" Returns the value in the current assignment of the variable of given index.""" 3122 return _pywrapcp.IntVarLocalSearchOperatorTemplate_Value(self, index)
Returns the value in the current assignment of the variable of given index.
3130 def OnStart(self) -> "void": 3131 r""" Called by Start() after synchronizing the operator with the current assignment. Should be overridden instead of Start() to avoid calling VarLocalSearchOperator::Start explicitly.""" 3132 return _pywrapcp.IntVarLocalSearchOperatorTemplate_OnStart(self)
Called by Start() after synchronizing the operator with the current assignment. Should be overridden instead of Start() to avoid calling VarLocalSearchOperator::Start explicitly.
Inherited Members
3137class IntVarLocalSearchOperator(IntVarLocalSearchOperatorTemplate): 3138 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3139 __repr__ = _swig_repr 3140 3141 def __init__(self, *args): 3142 if self.__class__ == IntVarLocalSearchOperator: 3143 _self = None 3144 else: 3145 _self = self 3146 _pywrapcp.IntVarLocalSearchOperator_swiginit(self, _pywrapcp.new_IntVarLocalSearchOperator(_self, *args)) 3147 __swig_destroy__ = _pywrapcp.delete_IntVarLocalSearchOperator 3148 3149 def NextNeighbor(self, delta: "Assignment", deltadelta: "Assignment") -> "bool": 3150 r""" Redefines MakeNextNeighbor to export a simpler interface. The calls to ApplyChanges() and RevertChanges() are factored in this method, hiding both delta and deltadelta from subclasses which only need to override MakeOneNeighbor(). Therefore this method should not be overridden. Override MakeOneNeighbor() instead.""" 3151 return _pywrapcp.IntVarLocalSearchOperator_NextNeighbor(self, delta, deltadelta) 3152 3153 def OneNeighbor(self) -> "bool": 3154 r""" Creates a new neighbor. It returns false when the neighborhood is completely explored. MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.""" 3155 return _pywrapcp.IntVarLocalSearchOperator_OneNeighbor(self) 3156 def __disown__(self): 3157 self.this.disown() 3158 _pywrapcp.disown_IntVarLocalSearchOperator(self) 3159 return weakref.proxy(self)
Base operator class for operators manipulating variables.
3149 def NextNeighbor(self, delta: "Assignment", deltadelta: "Assignment") -> "bool": 3150 r""" Redefines MakeNextNeighbor to export a simpler interface. The calls to ApplyChanges() and RevertChanges() are factored in this method, hiding both delta and deltadelta from subclasses which only need to override MakeOneNeighbor(). Therefore this method should not be overridden. Override MakeOneNeighbor() instead.""" 3151 return _pywrapcp.IntVarLocalSearchOperator_NextNeighbor(self, delta, deltadelta)
Redefines MakeNextNeighbor to export a simpler interface. The calls to ApplyChanges() and RevertChanges() are factored in this method, hiding both delta and deltadelta from subclasses which only need to override MakeOneNeighbor(). Therefore this method should not be overridden. Override MakeOneNeighbor() instead.
3153 def OneNeighbor(self) -> "bool": 3154 r""" Creates a new neighbor. It returns false when the neighborhood is completely explored. MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.""" 3155 return _pywrapcp.IntVarLocalSearchOperator_OneNeighbor(self)
Creates a new neighbor. It returns false when the neighborhood is completely explored. MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.
Inherited Members
3164class SequenceVarLocalSearchOperatorTemplate(LocalSearchOperator): 3165 r""" Base operator class for operators manipulating variables.""" 3166 3167 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3168 3169 def __init__(self, *args, **kwargs): 3170 raise AttributeError("No constructor defined - class is abstract") 3171 __repr__ = _swig_repr 3172 3173 def Start(self, assignment: "Assignment") -> "void": 3174 r""" This method should not be overridden. Override OnStart() instead which is called before exiting this method.""" 3175 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_Start(self, assignment) 3176 3177 def IsIncremental(self) -> "bool": 3178 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_IsIncremental(self) 3179 3180 def Size(self) -> "int": 3181 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_Size(self) 3182 3183 def Value(self, index: "int64_t") -> "std::vector< int > const &": 3184 r""" Returns the value in the current assignment of the variable of given index.""" 3185 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_Value(self, index) 3186 3187 def OldValue(self, index: "int64_t") -> "std::vector< int > const &": 3188 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_OldValue(self, index) 3189 3190 def SetValue(self, index: "int64_t", value: "std::vector< int > const &") -> "void": 3191 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_SetValue(self, index, value) 3192 3193 def OnStart(self) -> "void": 3194 r""" Called by Start() after synchronizing the operator with the current assignment. Should be overridden instead of Start() to avoid calling VarLocalSearchOperator::Start explicitly.""" 3195 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_OnStart(self)
Base operator class for operators manipulating variables.
3173 def Start(self, assignment: "Assignment") -> "void": 3174 r""" This method should not be overridden. Override OnStart() instead which is called before exiting this method.""" 3175 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_Start(self, assignment)
This method should not be overridden. Override OnStart() instead which is called before exiting this method.
3183 def Value(self, index: "int64_t") -> "std::vector< int > const &": 3184 r""" Returns the value in the current assignment of the variable of given index.""" 3185 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_Value(self, index)
Returns the value in the current assignment of the variable of given index.
3193 def OnStart(self) -> "void": 3194 r""" Called by Start() after synchronizing the operator with the current assignment. Should be overridden instead of Start() to avoid calling VarLocalSearchOperator::Start explicitly.""" 3195 return _pywrapcp.SequenceVarLocalSearchOperatorTemplate_OnStart(self)
Called by Start() after synchronizing the operator with the current assignment. Should be overridden instead of Start() to avoid calling VarLocalSearchOperator::Start explicitly.
Inherited Members
3200class SequenceVarLocalSearchOperator(SequenceVarLocalSearchOperatorTemplate): 3201 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3202 3203 def __init__(self, *args, **kwargs): 3204 raise AttributeError("No constructor defined - class is abstract") 3205 __repr__ = _swig_repr
Base operator class for operators manipulating variables.
3210class BaseLns(IntVarLocalSearchOperator): 3211 r""" This is the base class for building an Lns operator. An Lns fragment is a collection of variables which will be relaxed. Fragments are built with NextFragment(), which returns false if there are no more fragments to build. Optionally one can override InitFragments, which is called from LocalSearchOperator::Start to initialize fragment data. Here's a sample relaxing one variable at a time: class OneVarLns : public BaseLns { public: OneVarLns(const std::vector<IntVar*>& vars) : BaseLns(vars), index_(0) {} virtual ~OneVarLns() {} virtual void InitFragments() { index_ = 0; } virtual bool NextFragment() { const int size = Size(); if (index_ < size) { AppendToFragment(index_); ++index_; return true; } else { return false; } } private: int index_; };""" 3212 3213 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3214 __repr__ = _swig_repr 3215 3216 def __init__(self, vars: "std::vector< operations_research::IntVar * > const &"): 3217 if self.__class__ == BaseLns: 3218 _self = None 3219 else: 3220 _self = self 3221 _pywrapcp.BaseLns_swiginit(self, _pywrapcp.new_BaseLns(_self, vars)) 3222 __swig_destroy__ = _pywrapcp.delete_BaseLns 3223 3224 def InitFragments(self) -> "void": 3225 return _pywrapcp.BaseLns_InitFragments(self) 3226 3227 def NextFragment(self) -> "bool": 3228 return _pywrapcp.BaseLns_NextFragment(self) 3229 3230 def AppendToFragment(self, index: "int") -> "void": 3231 return _pywrapcp.BaseLns_AppendToFragment(self, index) 3232 3233 def FragmentSize(self) -> "int": 3234 return _pywrapcp.BaseLns_FragmentSize(self) 3235 3236 def __getitem__(self, index: "int") -> "int64_t": 3237 return _pywrapcp.BaseLns___getitem__(self, index) 3238 3239 def __len__(self) -> "int": 3240 return _pywrapcp.BaseLns___len__(self) 3241 def __disown__(self): 3242 self.this.disown() 3243 _pywrapcp.disown_BaseLns(self) 3244 return weakref.proxy(self)
This is the base class for building an Lns operator. An Lns fragment is a collection of variables which will be relaxed. Fragments are built with NextFragment(), which returns false if there are no more fragments to build. Optionally one can override InitFragments, which is called from LocalSearchOperator::Start to initialize fragment data. Here's a sample relaxing one variable at a time: class OneVarLns : public BaseLns { public: OneVarLns(const std::vector
3249class ChangeValue(IntVarLocalSearchOperator): 3250 r""" Defines operators which change the value of variables; each neighbor corresponds to *one* modified variable. Sub-classes have to define ModifyValue which determines what the new variable value is going to be (given the current value and the variable).""" 3251 3252 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3253 __repr__ = _swig_repr 3254 3255 def __init__(self, vars: "std::vector< operations_research::IntVar * > const &"): 3256 if self.__class__ == ChangeValue: 3257 _self = None 3258 else: 3259 _self = self 3260 _pywrapcp.ChangeValue_swiginit(self, _pywrapcp.new_ChangeValue(_self, vars)) 3261 __swig_destroy__ = _pywrapcp.delete_ChangeValue 3262 3263 def ModifyValue(self, index: "int64_t", value: "int64_t") -> "int64_t": 3264 return _pywrapcp.ChangeValue_ModifyValue(self, index, value) 3265 3266 def OneNeighbor(self) -> "bool": 3267 r""" This method should not be overridden. Override ModifyValue() instead.""" 3268 return _pywrapcp.ChangeValue_OneNeighbor(self) 3269 def __disown__(self): 3270 self.this.disown() 3271 _pywrapcp.disown_ChangeValue(self) 3272 return weakref.proxy(self)
Defines operators which change the value of variables; each neighbor corresponds to one modified variable. Sub-classes have to define ModifyValue which determines what the new variable value is going to be (given the current value and the variable).
3277class PathOperator(IntVarLocalSearchOperator): 3278 r""" Base class of the local search operators dedicated to path modifications (a path is a set of nodes linked together by arcs). This family of neighborhoods supposes they are handling next variables representing the arcs (var[i] represents the node immediately after i on a path). Several services are provided: - arc manipulators (SetNext(), ReverseChain(), MoveChain()) - path inspectors (Next(), Prev(), IsPathEnd()) - path iterators: operators need a given number of nodes to define a neighbor; this class provides the iteration on a given number of (base) nodes which can be used to define a neighbor (through the BaseNode method) Subclasses only need to override MakeNeighbor to create neighbors using the services above (no direct manipulation of assignments).""" 3279 3280 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3281 3282 def __init__(self, *args, **kwargs): 3283 raise AttributeError("No constructor defined - class is abstract") 3284 __repr__ = _swig_repr 3285 3286 def Neighbor(self) -> "bool": 3287 return _pywrapcp.PathOperator_Neighbor(self)
Base class of the local search operators dedicated to path modifications (a path is a set of nodes linked together by arcs). This family of neighborhoods supposes they are handling next variables representing the arcs (var[i] represents the node immediately after i on a path). Several services are provided: - arc manipulators (SetNext(), ReverseChain(), MoveChain()) - path inspectors (Next(), Prev(), IsPathEnd()) - path iterators: operators need a given number of nodes to define a neighbor; this class provides the iteration on a given number of (base) nodes which can be used to define a neighbor (through the BaseNode method) Subclasses only need to override MakeNeighbor to create neighbors using the services above (no direct manipulation of assignments).
3292class LocalSearchFilter(BaseObject): 3293 r""" Classes to which this template function can be applied to as of 04/2014. Usage: LocalSearchOperator* op = MakeLocalSearchOperator<Relocate>(...); class TwoOpt; class Relocate; class Exchange; class Cross; class MakeActiveOperator; class MakeInactiveOperator; class MakeChainInactiveOperator; class SwapActiveOperator; class ExtendedSwapActiveOperator; class MakeActiveAndRelocate; class RelocateAndMakeActiveOperator; class RelocateAndMakeInactiveOperator; Local Search Filters are used for fast neighbor pruning. Filtering a move is done in several phases: - in the Relax phase, filters determine which parts of their internals will be changed by the candidate, and modify intermediary State - in the Accept phase, filters check that the candidate is feasible, - if the Accept phase succeeds, the solver may decide to trigger a Synchronize phase that makes filters change their internal representation to the last candidate, - otherwise (Accept fails or the solver does not want to synchronize), a Revert phase makes filters erase any intermediary State generated by the Relax and Accept phases. A given filter has phases called with the following pattern: (Relax.Accept.Synchronize | Relax.Accept.Revert | Relax.Revert)*. Filters's Revert() is always called in the reverse order their Accept() was called, to allow late filters to use state done/undone by early filters' Accept()/Revert().""" 3294 3295 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3296 3297 def __init__(self, *args, **kwargs): 3298 raise AttributeError("No constructor defined - class is abstract") 3299 __repr__ = _swig_repr 3300 3301 def Accept(self, delta: "Assignment", deltadelta: "Assignment", objective_min: "int64_t", objective_max: "int64_t") -> "bool": 3302 r""" Accepts a "delta" given the assignment with which the filter has been synchronized; the delta holds the variables which have been modified and their new value. If the filter represents a part of the global objective, its contribution must be between objective_min and objective_max. Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1, for the assignment (a,1), (b,0), the delta (b,1) will be rejected but the delta (a,0) will be accepted. TODO(user): Remove arguments when there are no more need for those.""" 3303 return _pywrapcp.LocalSearchFilter_Accept(self, delta, deltadelta, objective_min, objective_max) 3304 3305 def IsIncremental(self) -> "bool": 3306 return _pywrapcp.LocalSearchFilter_IsIncremental(self) 3307 3308 def Synchronize(self, assignment: "Assignment", delta: "Assignment") -> "void": 3309 r""" Synchronizes the filter with the current solution, delta being the difference with the solution passed to the previous call to Synchronize() or IncrementalSynchronize(). 'delta' can be used to incrementally synchronizing the filter with the new solution by only considering the changes in delta.""" 3310 return _pywrapcp.LocalSearchFilter_Synchronize(self, assignment, delta) 3311 __swig_destroy__ = _pywrapcp.delete_LocalSearchFilter
Classes to which this template function can be applied to as of 04/2014. Usage: LocalSearchOperator* op = MakeLocalSearchOperator
3301 def Accept(self, delta: "Assignment", deltadelta: "Assignment", objective_min: "int64_t", objective_max: "int64_t") -> "bool": 3302 r""" Accepts a "delta" given the assignment with which the filter has been synchronized; the delta holds the variables which have been modified and their new value. If the filter represents a part of the global objective, its contribution must be between objective_min and objective_max. Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1, for the assignment (a,1), (b,0), the delta (b,1) will be rejected but the delta (a,0) will be accepted. TODO(user): Remove arguments when there are no more need for those.""" 3303 return _pywrapcp.LocalSearchFilter_Accept(self, delta, deltadelta, objective_min, objective_max)
Accepts a "delta" given the assignment with which the filter has been synchronized; the delta holds the variables which have been modified and their new value. If the filter represents a part of the global objective, its contribution must be between objective_min and objective_max. Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1, for the assignment (a,1), (b,0), the delta (b,1) will be rejected but the delta (a,0) will be accepted. TODO(user): Remove arguments when there are no more need for those.
3308 def Synchronize(self, assignment: "Assignment", delta: "Assignment") -> "void": 3309 r""" Synchronizes the filter with the current solution, delta being the difference with the solution passed to the previous call to Synchronize() or IncrementalSynchronize(). 'delta' can be used to incrementally synchronizing the filter with the new solution by only considering the changes in delta.""" 3310 return _pywrapcp.LocalSearchFilter_Synchronize(self, assignment, delta)
Synchronizes the filter with the current solution, delta being the difference with the solution passed to the previous call to Synchronize() or IncrementalSynchronize(). 'delta' can be used to incrementally synchronizing the filter with the new solution by only considering the changes in delta.
Inherited Members
3316class LocalSearchFilterManager(BaseObject): 3317 r""" Filter manager: when a move is made, filters are executed to decide whether the solution is feasible and compute parts of the new cost. This class schedules filter execution and composes costs as a sum.""" 3318 3319 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3320 __repr__ = _swig_repr 3321 3322 def DebugString(self) -> "std::string": 3323 return _pywrapcp.LocalSearchFilterManager_DebugString(self) 3324 3325 def __init__(self, *args): 3326 _pywrapcp.LocalSearchFilterManager_swiginit(self, _pywrapcp.new_LocalSearchFilterManager(*args)) 3327 3328 def Accept(self, monitor: "operations_research::LocalSearchMonitor *const", delta: "Assignment", deltadelta: "Assignment", objective_min: "int64_t", objective_max: "int64_t") -> "bool": 3329 r""" Returns true iff all filters return true, and the sum of their accepted objectives is between objective_min and objective_max. The monitor has its Begin/EndFiltering events triggered.""" 3330 return _pywrapcp.LocalSearchFilterManager_Accept(self, monitor, delta, deltadelta, objective_min, objective_max) 3331 3332 def Synchronize(self, assignment: "Assignment", delta: "Assignment") -> "void": 3333 r""" Synchronizes all filters to assignment.""" 3334 return _pywrapcp.LocalSearchFilterManager_Synchronize(self, assignment, delta) 3335 __swig_destroy__ = _pywrapcp.delete_LocalSearchFilterManager
Filter manager: when a move is made, filters are executed to decide whether the solution is feasible and compute parts of the new cost. This class schedules filter execution and composes costs as a sum.
3328 def Accept(self, monitor: "operations_research::LocalSearchMonitor *const", delta: "Assignment", deltadelta: "Assignment", objective_min: "int64_t", objective_max: "int64_t") -> "bool": 3329 r""" Returns true iff all filters return true, and the sum of their accepted objectives is between objective_min and objective_max. The monitor has its Begin/EndFiltering events triggered.""" 3330 return _pywrapcp.LocalSearchFilterManager_Accept(self, monitor, delta, deltadelta, objective_min, objective_max)
Returns true iff all filters return true, and the sum of their accepted objectives is between objective_min and objective_max. The monitor has its Begin/EndFiltering events triggered.
3332 def Synchronize(self, assignment: "Assignment", delta: "Assignment") -> "void": 3333 r""" Synchronizes all filters to assignment.""" 3334 return _pywrapcp.LocalSearchFilterManager_Synchronize(self, assignment, delta)
Synchronizes all filters to assignment.
3340class IntVarLocalSearchFilter(LocalSearchFilter): 3341 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3342 __repr__ = _swig_repr 3343 3344 def __init__(self, vars: "std::vector< operations_research::IntVar * > const &"): 3345 if self.__class__ == IntVarLocalSearchFilter: 3346 _self = None 3347 else: 3348 _self = self 3349 _pywrapcp.IntVarLocalSearchFilter_swiginit(self, _pywrapcp.new_IntVarLocalSearchFilter(_self, vars)) 3350 __swig_destroy__ = _pywrapcp.delete_IntVarLocalSearchFilter 3351 3352 def Synchronize(self, assignment: "Assignment", delta: "Assignment") -> "void": 3353 r""" This method should not be overridden. Override OnSynchronize() instead which is called before exiting this method.""" 3354 return _pywrapcp.IntVarLocalSearchFilter_Synchronize(self, assignment, delta) 3355 3356 def Size(self) -> "int": 3357 return _pywrapcp.IntVarLocalSearchFilter_Size(self) 3358 3359 def Value(self, index: "int") -> "int64_t": 3360 return _pywrapcp.IntVarLocalSearchFilter_Value(self, index) 3361 3362 def IndexFromVar(self, var: "IntVar") -> "int64_t": 3363 return _pywrapcp.IntVarLocalSearchFilter_IndexFromVar(self, var) 3364 def __disown__(self): 3365 self.this.disown() 3366 _pywrapcp.disown_IntVarLocalSearchFilter(self) 3367 return weakref.proxy(self)
Classes to which this template function can be applied to as of 04/2014. Usage: LocalSearchOperator* op = MakeLocalSearchOperator
3352 def Synchronize(self, assignment: "Assignment", delta: "Assignment") -> "void": 3353 r""" This method should not be overridden. Override OnSynchronize() instead which is called before exiting this method.""" 3354 return _pywrapcp.IntVarLocalSearchFilter_Synchronize(self, assignment, delta)
This method should not be overridden. Override OnSynchronize() instead which is called before exiting this method.
Inherited Members
3372class BooleanVar(IntVar): 3373 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3374 3375 def __init__(self, *args, **kwargs): 3376 raise AttributeError("No constructor defined - class is abstract") 3377 __repr__ = _swig_repr 3378 3379 def Min(self) -> "int64_t": 3380 return _pywrapcp.BooleanVar_Min(self) 3381 3382 def SetMin(self, m: "int64_t") -> "void": 3383 return _pywrapcp.BooleanVar_SetMin(self, m) 3384 3385 def Max(self) -> "int64_t": 3386 return _pywrapcp.BooleanVar_Max(self) 3387 3388 def SetMax(self, m: "int64_t") -> "void": 3389 return _pywrapcp.BooleanVar_SetMax(self, m) 3390 3391 def SetRange(self, mi: "int64_t", ma: "int64_t") -> "void": 3392 return _pywrapcp.BooleanVar_SetRange(self, mi, ma) 3393 3394 def Bound(self) -> "bool": 3395 return _pywrapcp.BooleanVar_Bound(self) 3396 3397 def Value(self) -> "int64_t": 3398 return _pywrapcp.BooleanVar_Value(self) 3399 3400 def RemoveValue(self, v: "int64_t") -> "void": 3401 return _pywrapcp.BooleanVar_RemoveValue(self, v) 3402 3403 def RemoveInterval(self, l: "int64_t", u: "int64_t") -> "void": 3404 return _pywrapcp.BooleanVar_RemoveInterval(self, l, u) 3405 3406 def WhenBound(self, d: "Demon") -> "void": 3407 return _pywrapcp.BooleanVar_WhenBound(self, d) 3408 3409 def WhenRange(self, d: "Demon") -> "void": 3410 return _pywrapcp.BooleanVar_WhenRange(self, d) 3411 3412 def WhenDomain(self, d: "Demon") -> "void": 3413 return _pywrapcp.BooleanVar_WhenDomain(self, d) 3414 3415 def Size(self) -> "uint64_t": 3416 return _pywrapcp.BooleanVar_Size(self) 3417 3418 def Contains(self, v: "int64_t") -> "bool": 3419 return _pywrapcp.BooleanVar_Contains(self, v) 3420 3421 def HoleIteratorAux(self, reversible: "bool") -> "operations_research::IntVarIterator *": 3422 return _pywrapcp.BooleanVar_HoleIteratorAux(self, reversible) 3423 3424 def DomainIteratorAux(self, reversible: "bool") -> "operations_research::IntVarIterator *": 3425 return _pywrapcp.BooleanVar_DomainIteratorAux(self, reversible) 3426 3427 def DebugString(self) -> "std::string": 3428 return _pywrapcp.BooleanVar_DebugString(self)
The class IntVar is a subset of IntExpr. In addition to the IntExpr protocol, it offers persistence, removing values from the domains, and a finer model for events.
3391 def SetRange(self, mi: "int64_t", ma: "int64_t") -> "void": 3392 return _pywrapcp.BooleanVar_SetRange(self, mi, ma)
This method sets both the min and the max of the expression.
This method returns the value of the variable. This method checks before that the variable is bound.
3400 def RemoveValue(self, v: "int64_t") -> "void": 3401 return _pywrapcp.BooleanVar_RemoveValue(self, v)
This method removes the value 'v' from the domain of the variable.
3403 def RemoveInterval(self, l: "int64_t", u: "int64_t") -> "void": 3404 return _pywrapcp.BooleanVar_RemoveInterval(self, l, u)
This method removes the interval 'l' .. 'u' from the domain of the variable. It assumes that 'l' <= 'u'.
Overload 1: This method attaches a demon that will be awakened when the variable is bound.
|
Overload 2: This method attaches a closure that will be awakened when the variable is bound.
Overload 1: Attach a demon that will watch the min or the max of the expression.
|
Overload 2: Attach a demon that will watch the min or the max of the expression.
3412 def WhenDomain(self, d: "Demon") -> "void": 3413 return _pywrapcp.BooleanVar_WhenDomain(self, d)
Overload 1: This method attaches a demon that will watch any domain modification of the domain of the variable.
|
Overload 2: This method attaches a closure that will watch any domain modification of the domain of the variable.
This method returns the number of values in the domain of the variable.
This method returns whether the value 'v' is in the domain of the variable.
3421 def HoleIteratorAux(self, reversible: "bool") -> "operations_research::IntVarIterator *": 3422 return _pywrapcp.BooleanVar_HoleIteratorAux(self, reversible)
Creates a hole iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.
3424 def DomainIteratorAux(self, reversible: "bool") -> "operations_research::IntVarIterator *": 3425 return _pywrapcp.BooleanVar_DomainIteratorAux(self, reversible)
Creates a domain iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.
3434class PyDecision(Decision): 3435 3436 def __init__(self): 3437 Decision.__init__(self) 3438 3439 def ApplyWrapper(self, solver): 3440 try: 3441 self.Apply(solver) 3442 except Exception as e: 3443 if 'CP Solver fail' in str(e): 3444 solver.ShouldFail() 3445 else: 3446 raise 3447 3448 def RefuteWrapper(self, solver): 3449 try: 3450 self.Refute(solver) 3451 except Exception as e: 3452 if 'CP Solver fail' in str(e): 3453 solver.ShouldFail() 3454 else: 3455 raise 3456 3457 def DebugString(self): 3458 return "PyDecision"
A Decision represents a choice point in the search tree. The two main methods are Apply() to go left, or Refute() to go right.
3439 def ApplyWrapper(self, solver): 3440 try: 3441 self.Apply(solver) 3442 except Exception as e: 3443 if 'CP Solver fail' in str(e): 3444 solver.ShouldFail() 3445 else: 3446 raise
Apply will be called first when the decision is executed.
3461class PyDecisionBuilder(DecisionBuilder): 3462 3463 def __init__(self): 3464 DecisionBuilder.__init__(self) 3465 3466 def NextWrapper(self, solver): 3467 try: 3468 return self.Next(solver) 3469 except Exception as e: 3470 if 'CP Solver fail' in str(e): 3471 return solver.FailDecision() 3472 else: 3473 raise 3474 3475 def DebugString(self): 3476 return "PyDecisionBuilder"
A DecisionBuilder is responsible for creating the search tree. The important method is Next(), which returns the next decision to execute.
3466 def NextWrapper(self, solver): 3467 try: 3468 return self.Next(solver) 3469 except Exception as e: 3470 if 'CP Solver fail' in str(e): 3471 return solver.FailDecision() 3472 else: 3473 raise
This is the main method of the decision builder class. It must return a decision (an instance of the class Decision). If it returns nullptr, this means that the decision builder has finished its work.
Inherited Members
3479class PyDemon(Demon): 3480 3481 def RunWrapper(self, solver): 3482 try: 3483 self.Run(solver) 3484 except Exception as e: 3485 if 'CP Solver fail' in str(e): 3486 solver.ShouldFail() 3487 else: 3488 raise 3489 3490 def DebugString(self): 3491 return "PyDemon"
A Demon is the base element of a propagation queue. It is the main object responsible for implementing the actual propagation of the constraint and pruning the inconsistent values in the domains of the variables. The main concept is that demons are listeners that are attached to the variables and listen to their modifications. There are two methods: - Run() is the actual method called when the demon is processed. - priority() returns its priority. Standard priorities are slow, normal or fast. "immediate" is reserved for variables and is treated separately.
3494class PyConstraintDemon(PyDemon): 3495 3496 def __init__(self, ct, method, delayed, *args): 3497 PyDemon.__init__(self) 3498 self.__constraint = ct 3499 self.__method = method 3500 self.__delayed = delayed 3501 self.__args = args 3502 3503 def Run(self, solver): 3504 self.__method(self.__constraint, *self.__args) 3505 3506 def Priority(self): 3507 return Solver.DELAYED_PRIORITY if self.__delayed else Solver.NORMAL_PRIORITY 3508 3509 def DebugString(self): 3510 return 'PyConstraintDemon'
A Demon is the base element of a propagation queue. It is the main object responsible for implementing the actual propagation of the constraint and pruning the inconsistent values in the domains of the variables. The main concept is that demons are listeners that are attached to the variables and listen to their modifications. There are two methods: - Run() is the actual method called when the demon is processed. - priority() returns its priority. Standard priorities are slow, normal or fast. "immediate" is reserved for variables and is treated separately.
3496 def __init__(self, ct, method, delayed, *args): 3497 PyDemon.__init__(self) 3498 self.__constraint = ct 3499 self.__method = method 3500 self.__delayed = delayed 3501 self.__args = args
This indicates the priority of a demon. Immediate demons are treated separately and corresponds to variables.
3506 def Priority(self): 3507 return Solver.DELAYED_PRIORITY if self.__delayed else Solver.NORMAL_PRIORITY
This method returns the priority of the demon. Usually a demon is fast, slow or normal. Immediate demons are reserved for internal use to maintain variables.
Inherited Members
3513class PyConstraint(Constraint): 3514 3515 def __init__(self, solver): 3516 Constraint.__init__(self, solver) 3517 self.__demons = [] 3518 3519 def Demon(self, method, *args): 3520 demon = PyConstraintDemon(self, method, False, *args) 3521 self.__demons.append(demon) 3522 return demon 3523 3524 def DelayedDemon(self, method, *args): 3525 demon = PyConstraintDemon(self, method, True, *args) 3526 self.__demons.append(demon) 3527 return demon 3528 3529 def InitialPropagateDemon(self): 3530 return self.solver().ConstraintInitialPropagateCallback(self) 3531 3532 def DelayedInitialPropagateDemon(self): 3533 return self.solver().DelayedConstraintInitialPropagateCallback(self) 3534 3535 def InitialPropagateWrapper(self): 3536 try: 3537 self.InitialPropagate() 3538 except Exception as e: 3539 if 'CP Solver fail' in str(e): 3540 self.solver().ShouldFail() 3541 else: 3542 raise 3543 3544 def DebugString(self): 3545 return "PyConstraint"
A constraint is the main modeling object. It provides two methods: - Post() is responsible for creating the demons and attaching them to immediate demons(). - InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.
3535 def InitialPropagateWrapper(self): 3536 try: 3537 self.InitialPropagate() 3538 except Exception as e: 3539 if 'CP Solver fail' in str(e): 3540 self.solver().ShouldFail() 3541 else: 3542 raise
This method performs the initial propagation of the constraint. It is called just after the post.
Inherited Members
3549class RoutingIndexManager(object): 3550 r""" Manager for any NodeIndex <-> variable index conversion. The routing solver uses variable indices internally and through its API. These variable indices are tricky to manage directly because one Node can correspond to a multitude of variables, depending on the number of times they appear in the model, and if they're used as start and/or end points. This class aims to simplify variable index usage, allowing users to use NodeIndex instead. Usage: .cpp} auto starts_ends = ...; /// These are NodeIndex. RoutingIndexManager manager(10, 4, starts_ends); // 10 nodes, 4 vehicles. RoutingModel model(manager);""" 3551 3552 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3553 __repr__ = _swig_repr 3554 3555 def __init__(self, *args): 3556 _pywrapcp.RoutingIndexManager_swiginit(self, _pywrapcp.new_RoutingIndexManager(*args)) 3557 __swig_destroy__ = _pywrapcp.delete_RoutingIndexManager 3558 3559 def GetNumberOfNodes(self) -> "int": 3560 return _pywrapcp.RoutingIndexManager_GetNumberOfNodes(self) 3561 3562 def GetNumberOfVehicles(self) -> "int": 3563 return _pywrapcp.RoutingIndexManager_GetNumberOfVehicles(self) 3564 3565 def GetNumberOfIndices(self) -> "int": 3566 return _pywrapcp.RoutingIndexManager_GetNumberOfIndices(self) 3567 3568 def GetStartIndex(self, vehicle: "int") -> "int64_t": 3569 return _pywrapcp.RoutingIndexManager_GetStartIndex(self, vehicle) 3570 3571 def GetEndIndex(self, vehicle: "int") -> "int64_t": 3572 return _pywrapcp.RoutingIndexManager_GetEndIndex(self, vehicle) 3573 3574 def NodeToIndex(self, node: "operations_research::RoutingIndexManager::NodeIndex") -> "int64_t": 3575 return _pywrapcp.RoutingIndexManager_NodeToIndex(self, node) 3576 3577 def IndexToNode(self, index: "int64_t") -> "operations_research::RoutingIndexManager::NodeIndex": 3578 return _pywrapcp.RoutingIndexManager_IndexToNode(self, index)
Manager for any NodeIndex <-> variable index conversion. The routing solver uses variable indices internally and through its API. These variable indices are tricky to manage directly because one Node can correspond to a multitude of variables, depending on the number of times they appear in the model, and if they're used as start and/or end points. This class aims to simplify variable index usage, allowing users to use NodeIndex instead. Usage: .cpp} auto starts_ends = ...; /// These are NodeIndex. RoutingIndexManager manager(10, 4, starts_ends); // 10 nodes, 4 vehicles. RoutingModel model(manager);
3590def FindErrorInRoutingSearchParameters(search_parameters: "operations_research::RoutingSearchParameters const &") -> "std::string": 3591 r""" Returns an empty std::string if the routing search parameters are valid, and a non-empty, human readable error description if they're not.""" 3592 return _pywrapcp.FindErrorInRoutingSearchParameters(search_parameters)
Returns an empty std::string if the routing search parameters are valid, and a non-empty, human readable error description if they're not.
3596class RoutingModel(object): 3597 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 3598 __repr__ = _swig_repr 3599 ROUTING_NOT_SOLVED = _pywrapcp.RoutingModel_ROUTING_NOT_SOLVED 3600 r""" Problem not solved yet (before calling RoutingModel::Solve()).""" 3601 ROUTING_SUCCESS = _pywrapcp.RoutingModel_ROUTING_SUCCESS 3602 r""" Problem solved successfully after calling RoutingModel::Solve().""" 3603 ROUTING_FAIL = _pywrapcp.RoutingModel_ROUTING_FAIL 3604 r""" No solution found to the problem after calling RoutingModel::Solve().""" 3605 ROUTING_FAIL_TIMEOUT = _pywrapcp.RoutingModel_ROUTING_FAIL_TIMEOUT 3606 r""" Time limit reached before finding a solution with RoutingModel::Solve().""" 3607 ROUTING_INVALID = _pywrapcp.RoutingModel_ROUTING_INVALID 3608 r""" Model, model parameters or flags are not valid.""" 3609 ROUTING_INFEASIBLE = _pywrapcp.RoutingModel_ROUTING_INFEASIBLE 3610 r""" Problem proven to be infeasible.""" 3611 PICKUP_AND_DELIVERY_NO_ORDER = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_NO_ORDER 3612 r""" Any precedence is accepted.""" 3613 PICKUP_AND_DELIVERY_LIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_LIFO 3614 r""" Deliveries must be performed in reverse order of pickups.""" 3615 PICKUP_AND_DELIVERY_FIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_FIFO 3616 r""" Deliveries must be performed in the same order as pickups.""" 3617 3618 def __init__(self, *args): 3619 _pywrapcp.RoutingModel_swiginit(self, _pywrapcp.new_RoutingModel(*args)) 3620 __swig_destroy__ = _pywrapcp.delete_RoutingModel 3621 3622 def RegisterUnaryTransitVector(self, values: "std::vector< int64_t >") -> "int": 3623 r""" Registers 'callback' and returns its index.""" 3624 return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values) 3625 3626 def RegisterUnaryTransitCallback(self, callback: "operations_research::RoutingModel::TransitCallback1") -> "int": 3627 return _pywrapcp.RoutingModel_RegisterUnaryTransitCallback(self, callback) 3628 3629 def RegisterPositiveUnaryTransitCallback(self, callback: "operations_research::RoutingModel::TransitCallback1") -> "int": 3630 return _pywrapcp.RoutingModel_RegisterPositiveUnaryTransitCallback(self, callback) 3631 3632 def RegisterTransitMatrix(self, values: "std::vector< std::vector< int64_t > >") -> "int": 3633 return _pywrapcp.RoutingModel_RegisterTransitMatrix(self, values) 3634 3635 def RegisterTransitCallback(self, callback: "operations_research::RoutingModel::TransitCallback2") -> "int": 3636 return _pywrapcp.RoutingModel_RegisterTransitCallback(self, callback) 3637 3638 def RegisterPositiveTransitCallback(self, callback: "operations_research::RoutingModel::TransitCallback2") -> "int": 3639 return _pywrapcp.RoutingModel_RegisterPositiveTransitCallback(self, callback) 3640 3641 def TransitCallback(self, callback_index: "int") -> "operations_research::RoutingModel::TransitCallback2 const &": 3642 return _pywrapcp.RoutingModel_TransitCallback(self, callback_index) 3643 3644 def UnaryTransitCallbackOrNull(self, callback_index: "int") -> "operations_research::RoutingModel::TransitCallback1 const &": 3645 return _pywrapcp.RoutingModel_UnaryTransitCallbackOrNull(self, callback_index) 3646 3647 def AddDimension(self, evaluator_index: "int", slack_max: "int64_t", capacity: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "bool": 3648 r""" Model creation Methods to add dimensions to routes; dimensions represent quantities accumulated at nodes along the routes. They represent quantities such as weights or volumes carried along the route, or distance or times. Quantities at a node are represented by "cumul" variables and the increase or decrease of quantities between nodes are represented by "transit" variables. These variables are linked as follows: if j == next(i), cumul(j) = cumul(i) + transit(i) + slack(i) where slack is a positive slack variable (can represent waiting times for a time dimension). Setting the value of fix_start_cumul_to_zero to true will force the "cumul" variable of the start node of all vehicles to be equal to 0. Creates a dimension where the transit variable is constrained to be equal to evaluator(i, next(i)); 'slack_max' is the upper bound of the slack variable and 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns false if a dimension with the same name has already been created (and doesn't create the new dimension). Takes ownership of the callback 'evaluator'.""" 3649 return _pywrapcp.RoutingModel_AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name) 3650 3651 def AddDimensionWithVehicleTransits(self, evaluator_indices: "std::vector< int > const &", slack_max: "int64_t", capacity: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "bool": 3652 return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name) 3653 3654 def AddDimensionWithVehicleCapacity(self, evaluator_index: "int", slack_max: "int64_t", vehicle_capacities: "std::vector< int64_t >", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "bool": 3655 return _pywrapcp.RoutingModel_AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name) 3656 3657 def AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices: "std::vector< int > const &", slack_max: "int64_t", vehicle_capacities: "std::vector< int64_t >", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "bool": 3658 return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name) 3659 3660 def AddConstantDimensionWithSlack(self, value: "int64_t", capacity: "int64_t", slack_max: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >": 3661 r""" Creates a dimension where the transit variable is constrained to be equal to 'value'; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered unary transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).""" 3662 return _pywrapcp.RoutingModel_AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name) 3663 3664 def AddConstantDimension(self, value: "int64_t", capacity: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >": 3665 return _pywrapcp.RoutingModel_AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name) 3666 3667 def AddVectorDimension(self, values: "std::vector< int64_t >", capacity: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >": 3668 r""" Creates a dimension where the transit variable is constrained to be equal to 'values[i]' for node i; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered unary transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).""" 3669 return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name) 3670 3671 def AddMatrixDimension(self, values: "std::vector< std::vector< int64_t > >", capacity: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >": 3672 r""" Creates a dimension where the transit variable is constrained to be equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).""" 3673 return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name) 3674 3675 def MakePathSpansAndTotalSlacks(self, dimension: "RoutingDimension", spans: "std::vector< operations_research::IntVar * >", total_slacks: "std::vector< operations_research::IntVar * >") -> "operations_research::Constraint *": 3676 r""" For every vehicle of the routing model: - if total_slacks[vehicle] is not nullptr, constrains it to be the sum of slacks on that vehicle, that is, dimension->CumulVar(end) - dimension->CumulVar(start) - sum_{node in path of vehicle} dimension->FixedTransitVar(node). - if spans[vehicle] is not nullptr, constrains it to be dimension->CumulVar(end) - dimension->CumulVar(start) This does stronger propagation than a decomposition, and takes breaks into account.""" 3677 return _pywrapcp.RoutingModel_MakePathSpansAndTotalSlacks(self, dimension, spans, total_slacks) 3678 3679 def GetAllDimensionNames(self) -> "std::vector< std::string >": 3680 r""" Outputs the names of all dimensions added to the routing engine.""" 3681 return _pywrapcp.RoutingModel_GetAllDimensionNames(self) 3682 3683 def GetDimensions(self) -> "std::vector< operations_research::RoutingDimension * > const &": 3684 r""" Returns all dimensions of the model.""" 3685 return _pywrapcp.RoutingModel_GetDimensions(self) 3686 3687 def GetDimensionsWithSoftOrSpanCosts(self) -> "std::vector< operations_research::RoutingDimension * >": 3688 r""" Returns dimensions with soft or vehicle span costs.""" 3689 return _pywrapcp.RoutingModel_GetDimensionsWithSoftOrSpanCosts(self) 3690 3691 def GetDimensionsWithGlobalCumulOptimizers(self) -> "std::vector< operations_research::RoutingDimension const * >": 3692 r""" Returns the dimensions which have [global|local]_dimension_optimizers_.""" 3693 return _pywrapcp.RoutingModel_GetDimensionsWithGlobalCumulOptimizers(self) 3694 3695 def GetDimensionsWithLocalCumulOptimizers(self) -> "std::vector< operations_research::RoutingDimension const * >": 3696 return _pywrapcp.RoutingModel_GetDimensionsWithLocalCumulOptimizers(self) 3697 3698 def HasGlobalCumulOptimizer(self, dimension: "RoutingDimension") -> "bool": 3699 r""" Returns whether the given dimension has global/local cumul optimizers.""" 3700 return _pywrapcp.RoutingModel_HasGlobalCumulOptimizer(self, dimension) 3701 3702 def HasLocalCumulOptimizer(self, dimension: "RoutingDimension") -> "bool": 3703 return _pywrapcp.RoutingModel_HasLocalCumulOptimizer(self, dimension) 3704 3705 def GetMutableGlobalCumulLPOptimizer(self, dimension: "RoutingDimension") -> "operations_research::GlobalDimensionCumulOptimizer *": 3706 r""" Returns the global/local dimension cumul optimizer for a given dimension, or nullptr if there is none.""" 3707 return _pywrapcp.RoutingModel_GetMutableGlobalCumulLPOptimizer(self, dimension) 3708 3709 def GetMutableGlobalCumulMPOptimizer(self, dimension: "RoutingDimension") -> "operations_research::GlobalDimensionCumulOptimizer *": 3710 return _pywrapcp.RoutingModel_GetMutableGlobalCumulMPOptimizer(self, dimension) 3711 3712 def GetMutableLocalCumulLPOptimizer(self, dimension: "RoutingDimension") -> "operations_research::LocalDimensionCumulOptimizer *": 3713 return _pywrapcp.RoutingModel_GetMutableLocalCumulLPOptimizer(self, dimension) 3714 3715 def GetMutableLocalCumulMPOptimizer(self, dimension: "RoutingDimension") -> "operations_research::LocalDimensionCumulOptimizer *": 3716 return _pywrapcp.RoutingModel_GetMutableLocalCumulMPOptimizer(self, dimension) 3717 3718 def HasDimension(self, dimension_name: "std::string const &") -> "bool": 3719 r""" Returns true if a dimension exists for a given dimension name.""" 3720 return _pywrapcp.RoutingModel_HasDimension(self, dimension_name) 3721 3722 def GetDimensionOrDie(self, dimension_name: "std::string const &") -> "operations_research::RoutingDimension const &": 3723 r""" Returns a dimension from its name. Dies if the dimension does not exist.""" 3724 return _pywrapcp.RoutingModel_GetDimensionOrDie(self, dimension_name) 3725 3726 def GetMutableDimension(self, dimension_name: "std::string const &") -> "operations_research::RoutingDimension *": 3727 r""" Returns a dimension from its name. Returns nullptr if the dimension does not exist.""" 3728 return _pywrapcp.RoutingModel_GetMutableDimension(self, dimension_name) 3729 3730 def SetPrimaryConstrainedDimension(self, dimension_name: "std::string const &") -> "void": 3731 r""" Set the given dimension as "primary constrained". As of August 2013, this is only used by ArcIsMoreConstrainedThanArc(). "dimension" must be the name of an existing dimension, or be empty, in which case there will not be a primary dimension after this call.""" 3732 return _pywrapcp.RoutingModel_SetPrimaryConstrainedDimension(self, dimension_name) 3733 3734 def GetPrimaryConstrainedDimension(self) -> "std::string const &": 3735 r""" Get the primary constrained dimension, or an empty string if it is unset.""" 3736 return _pywrapcp.RoutingModel_GetPrimaryConstrainedDimension(self) 3737 3738 def AddResourceGroup(self) -> "int": 3739 r""" Adds a resource group to the routing model. Returns its index in resource_groups_.""" 3740 return _pywrapcp.RoutingModel_AddResourceGroup(self) 3741 3742 def GetResourceGroups(self) -> "std::vector< std::unique_ptr< operations_research::RoutingModel::ResourceGroup > > const &": 3743 return _pywrapcp.RoutingModel_GetResourceGroups(self) 3744 3745 def GetResourceGroup(self, rg_index: "int") -> "operations_research::RoutingModel::ResourceGroup *": 3746 return _pywrapcp.RoutingModel_GetResourceGroup(self, rg_index) 3747 3748 def GetDimensionResourceGroupIndices(self, dimension: "RoutingDimension") -> "std::vector< int > const &": 3749 r""" Returns the indices of resource groups for this dimension. This method can only be called after the model has been closed.""" 3750 return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndices(self, dimension) 3751 3752 def GetDimensionResourceGroupIndex(self, dimension: "RoutingDimension") -> "int": 3753 r""" Returns the index of the resource group attached to the dimension. DCHECKS that there's exactly one resource group for this dimension.""" 3754 return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndex(self, dimension) 3755 3756 def AddDisjunction(self, *args) -> "operations_research::RoutingModel::DisjunctionIndex": 3757 r""" Adds a disjunction constraint on the indices: exactly 'max_cardinality' of the indices are active. Start and end indices of any vehicle cannot be part of a disjunction. If a penalty is given, at most 'max_cardinality' of the indices can be active, and if less are active, 'penalty' is payed per inactive index. This is equivalent to adding the constraint: p + Sum(i)active[i] == max_cardinality where p is an integer variable, and the following cost to the cost function: p * penalty. 'penalty' must be positive to make the disjunction optional; a negative penalty will force 'max_cardinality' indices of the disjunction to be performed, and therefore p == 0. Note: passing a vector with a single index will model an optional index with a penalty cost if it is not visited.""" 3758 return _pywrapcp.RoutingModel_AddDisjunction(self, *args) 3759 3760 def GetDisjunctionIndices(self, index: "int64_t") -> "std::vector< operations_research::RoutingModel::DisjunctionIndex > const &": 3761 r""" Returns the indices of the disjunctions to which an index belongs.""" 3762 return _pywrapcp.RoutingModel_GetDisjunctionIndices(self, index) 3763 3764 def GetDisjunctionPenalty(self, index: "operations_research::RoutingModel::DisjunctionIndex") -> "int64_t": 3765 r""" Returns the penalty of the node disjunction of index 'index'.""" 3766 return _pywrapcp.RoutingModel_GetDisjunctionPenalty(self, index) 3767 3768 def GetDisjunctionMaxCardinality(self, index: "operations_research::RoutingModel::DisjunctionIndex") -> "int64_t": 3769 r""" Returns the maximum number of possible active nodes of the node disjunction of index 'index'.""" 3770 return _pywrapcp.RoutingModel_GetDisjunctionMaxCardinality(self, index) 3771 3772 def GetNumberOfDisjunctions(self) -> "int": 3773 r""" Returns the number of node disjunctions in the model.""" 3774 return _pywrapcp.RoutingModel_GetNumberOfDisjunctions(self) 3775 3776 def HasMandatoryDisjunctions(self) -> "bool": 3777 r""" Returns true if the model contains mandatory disjunctions (ones with kNoPenalty as penalty).""" 3778 return _pywrapcp.RoutingModel_HasMandatoryDisjunctions(self) 3779 3780 def HasMaxCardinalityConstrainedDisjunctions(self) -> "bool": 3781 r""" Returns true if the model contains at least one disjunction which is constrained by its max_cardinality.""" 3782 return _pywrapcp.RoutingModel_HasMaxCardinalityConstrainedDisjunctions(self) 3783 3784 def GetPerfectBinaryDisjunctions(self) -> "std::vector< std::pair< int64_t,int64_t > >": 3785 r""" Returns the list of all perfect binary disjunctions, as pairs of variable indices: a disjunction is "perfect" when its variables do not appear in any other disjunction. Each pair is sorted (lowest variable index first), and the output vector is also sorted (lowest pairs first).""" 3786 return _pywrapcp.RoutingModel_GetPerfectBinaryDisjunctions(self) 3787 3788 def IgnoreDisjunctionsAlreadyForcedToZero(self) -> "void": 3789 r""" SPECIAL: Makes the solver ignore all the disjunctions whose active variables are all trivially zero (i.e. Max() == 0), by setting their max_cardinality to 0. This can be useful when using the BaseBinaryDisjunctionNeighborhood operators, in the context of arc-based routing.""" 3790 return _pywrapcp.RoutingModel_IgnoreDisjunctionsAlreadyForcedToZero(self) 3791 3792 def AddSoftSameVehicleConstraint(self, indices: "std::vector< int64_t > const &", cost: "int64_t") -> "void": 3793 r""" Adds a soft constraint to force a set of variable indices to be on the same vehicle. If all nodes are not on the same vehicle, each extra vehicle used adds 'cost' to the cost function.""" 3794 return _pywrapcp.RoutingModel_AddSoftSameVehicleConstraint(self, indices, cost) 3795 3796 def SetAllowedVehiclesForIndex(self, vehicles: "std::vector< int > const &", index: "int64_t") -> "void": 3797 r""" Sets the vehicles which can visit a given node. If the node is in a disjunction, this will not prevent it from being unperformed. Specifying an empty vector of vehicles has no effect (all vehicles will be allowed to visit the node).""" 3798 return _pywrapcp.RoutingModel_SetAllowedVehiclesForIndex(self, vehicles, index) 3799 3800 def IsVehicleAllowedForIndex(self, vehicle: "int", index: "int64_t") -> "bool": 3801 r""" Returns true if a vehicle is allowed to visit a given node.""" 3802 return _pywrapcp.RoutingModel_IsVehicleAllowedForIndex(self, vehicle, index) 3803 3804 def AddPickupAndDelivery(self, pickup: "int64_t", delivery: "int64_t") -> "void": 3805 r""" Notifies that index1 and index2 form a pair of nodes which should belong to the same route. This methods helps the search find better solutions, especially in the local search phase. It should be called each time you have an equality constraint linking the vehicle variables of two node (including for instance pickup and delivery problems): Solver* const solver = routing.solver(); int64_t index1 = manager.NodeToIndex(node1); int64_t index2 = manager.NodeToIndex(node2); solver->AddConstraint(solver->MakeEquality( routing.VehicleVar(index1), routing.VehicleVar(index2))); routing.AddPickupAndDelivery(index1, index2);""" 3806 return _pywrapcp.RoutingModel_AddPickupAndDelivery(self, pickup, delivery) 3807 3808 def AddPickupAndDeliverySets(self, pickup_disjunction: "operations_research::RoutingModel::DisjunctionIndex", delivery_disjunction: "operations_research::RoutingModel::DisjunctionIndex") -> "void": 3809 r""" Same as AddPickupAndDelivery but notifying that the performed node from the disjunction of index 'pickup_disjunction' is on the same route as the performed node from the disjunction of index 'delivery_disjunction'.""" 3810 return _pywrapcp.RoutingModel_AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction) 3811 3812 def GetPickupIndexPairs(self, node_index: "int64_t") -> "std::vector< std::pair< int,int > > const &": 3813 r""" Returns pairs for which the node is a pickup; the first element of each pair is the index in the pickup and delivery pairs list in which the pickup appears, the second element is its index in the pickups list.""" 3814 return _pywrapcp.RoutingModel_GetPickupIndexPairs(self, node_index) 3815 3816 def GetDeliveryIndexPairs(self, node_index: "int64_t") -> "std::vector< std::pair< int,int > > const &": 3817 r""" Same as above for deliveries.""" 3818 return _pywrapcp.RoutingModel_GetDeliveryIndexPairs(self, node_index) 3819 3820 def SetPickupAndDeliveryPolicyOfAllVehicles(self, policy: "operations_research::RoutingModel::PickupAndDeliveryPolicy") -> "void": 3821 r""" Sets the Pickup and delivery policy of all vehicles. It is equivalent to calling SetPickupAndDeliveryPolicyOfVehicle on all vehicles.""" 3822 return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfAllVehicles(self, policy) 3823 3824 def SetPickupAndDeliveryPolicyOfVehicle(self, policy: "operations_research::RoutingModel::PickupAndDeliveryPolicy", vehicle: "int") -> "void": 3825 return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle) 3826 3827 def GetPickupAndDeliveryPolicyOfVehicle(self, vehicle: "int") -> "operations_research::RoutingModel::PickupAndDeliveryPolicy": 3828 return _pywrapcp.RoutingModel_GetPickupAndDeliveryPolicyOfVehicle(self, vehicle) 3829 3830 def GetNumOfSingletonNodes(self) -> "int": 3831 r""" Returns the number of non-start/end nodes which do not appear in a pickup/delivery pair.""" 3832 return _pywrapcp.RoutingModel_GetNumOfSingletonNodes(self) 3833 TYPE_ADDED_TO_VEHICLE = _pywrapcp.RoutingModel_TYPE_ADDED_TO_VEHICLE 3834 r""" When visited, the number of types 'T' on the vehicle increases by one.""" 3835 ADDED_TYPE_REMOVED_FROM_VEHICLE = _pywrapcp.RoutingModel_ADDED_TYPE_REMOVED_FROM_VEHICLE 3836 r""" When visited, one instance of type 'T' previously added to the route (TYPE_ADDED_TO_VEHICLE), if any, is removed from the vehicle. If the type was not previously added to the route or all added instances have already been removed, this visit has no effect on the types.""" 3837 TYPE_ON_VEHICLE_UP_TO_VISIT = _pywrapcp.RoutingModel_TYPE_ON_VEHICLE_UP_TO_VISIT 3838 r""" With the following policy, the visit enforces that type 'T' is considered on the route from its start until this node is visited.""" 3839 TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED = _pywrapcp.RoutingModel_TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED 3840 r""" The visit doesn't have an impact on the number of types 'T' on the route, as it's (virtually) added and removed directly. This policy can be used for visits which are part of an incompatibility or requirement set without affecting the type count on the route.""" 3841 3842 def SetVisitType(self, index: "int64_t", type: "int", type_policy: "operations_research::RoutingModel::VisitTypePolicy") -> "void": 3843 return _pywrapcp.RoutingModel_SetVisitType(self, index, type, type_policy) 3844 3845 def GetVisitType(self, index: "int64_t") -> "int": 3846 return _pywrapcp.RoutingModel_GetVisitType(self, index) 3847 3848 def GetSingleNodesOfType(self, type: "int") -> "std::vector< int > const &": 3849 return _pywrapcp.RoutingModel_GetSingleNodesOfType(self, type) 3850 3851 def GetPairIndicesOfType(self, type: "int") -> "std::vector< int > const &": 3852 return _pywrapcp.RoutingModel_GetPairIndicesOfType(self, type) 3853 3854 def GetVisitTypePolicy(self, index: "int64_t") -> "operations_research::RoutingModel::VisitTypePolicy": 3855 return _pywrapcp.RoutingModel_GetVisitTypePolicy(self, index) 3856 3857 def CloseVisitTypes(self) -> "void": 3858 r""" This function should be called once all node visit types have been set and prior to adding any incompatibilities/requirements. "close" types.""" 3859 return _pywrapcp.RoutingModel_CloseVisitTypes(self) 3860 3861 def GetNumberOfVisitTypes(self) -> "int": 3862 return _pywrapcp.RoutingModel_GetNumberOfVisitTypes(self) 3863 3864 def AddHardTypeIncompatibility(self, type1: "int", type2: "int") -> "void": 3865 r""" Incompatibilities: Two nodes with "hard" incompatible types cannot share the same route at all, while with a "temporal" incompatibility they can't be on the same route at the same time.""" 3866 return _pywrapcp.RoutingModel_AddHardTypeIncompatibility(self, type1, type2) 3867 3868 def AddTemporalTypeIncompatibility(self, type1: "int", type2: "int") -> "void": 3869 return _pywrapcp.RoutingModel_AddTemporalTypeIncompatibility(self, type1, type2) 3870 3871 def GetHardTypeIncompatibilitiesOfType(self, type: "int") -> "absl::flat_hash_set< int > const &": 3872 r""" Returns visit types incompatible with a given type.""" 3873 return _pywrapcp.RoutingModel_GetHardTypeIncompatibilitiesOfType(self, type) 3874 3875 def GetTemporalTypeIncompatibilitiesOfType(self, type: "int") -> "absl::flat_hash_set< int > const &": 3876 return _pywrapcp.RoutingModel_GetTemporalTypeIncompatibilitiesOfType(self, type) 3877 3878 def HasHardTypeIncompatibilities(self) -> "bool": 3879 r""" Returns true iff any hard (resp. temporal) type incompatibilities have been added to the model.""" 3880 return _pywrapcp.RoutingModel_HasHardTypeIncompatibilities(self) 3881 3882 def HasTemporalTypeIncompatibilities(self) -> "bool": 3883 return _pywrapcp.RoutingModel_HasTemporalTypeIncompatibilities(self) 3884 3885 def AddSameVehicleRequiredTypeAlternatives(self, dependent_type: "int", required_type_alternatives: "absl::flat_hash_set< int >") -> "void": 3886 r""" Requirements: NOTE: As of 2019-04, cycles in the requirement graph are not supported, and lead to the dependent nodes being skipped if possible (otherwise the model is considered infeasible). The following functions specify that "dependent_type" requires at least one of the types in "required_type_alternatives". For same-vehicle requirements, a node of dependent type type_D requires at least one node of type type_R among the required alternatives on the same route.""" 3887 return _pywrapcp.RoutingModel_AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives) 3888 3889 def AddRequiredTypeAlternativesWhenAddingType(self, dependent_type: "int", required_type_alternatives: "absl::flat_hash_set< int >") -> "void": 3890 r""" If type_D depends on type_R when adding type_D, any node_D of type_D and VisitTypePolicy TYPE_ADDED_TO_VEHICLE or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED requires at least one type_R on its vehicle at the time node_D is visited.""" 3891 return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives) 3892 3893 def AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type: "int", required_type_alternatives: "absl::flat_hash_set< int >") -> "void": 3894 r""" The following requirements apply when visiting dependent nodes that remove their type from the route, i.e. type_R must be on the vehicle when type_D of VisitTypePolicy ADDED_TYPE_REMOVED_FROM_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED is visited.""" 3895 return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives) 3896 3897 def GetSameVehicleRequiredTypeAlternativesOfType(self, type: "int") -> "std::vector< absl::flat_hash_set< int > > const &": 3898 r""" Returns the set of same-vehicle requirement alternatives for the given type.""" 3899 return _pywrapcp.RoutingModel_GetSameVehicleRequiredTypeAlternativesOfType(self, type) 3900 3901 def GetRequiredTypeAlternativesWhenAddingType(self, type: "int") -> "std::vector< absl::flat_hash_set< int > > const &": 3902 r""" Returns the set of requirement alternatives when adding the given type.""" 3903 return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenAddingType(self, type) 3904 3905 def GetRequiredTypeAlternativesWhenRemovingType(self, type: "int") -> "std::vector< absl::flat_hash_set< int > > const &": 3906 r""" Returns the set of requirement alternatives when removing the given type.""" 3907 return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenRemovingType(self, type) 3908 3909 def HasSameVehicleTypeRequirements(self) -> "bool": 3910 r""" Returns true iff any same-route (resp. temporal) type requirements have been added to the model.""" 3911 return _pywrapcp.RoutingModel_HasSameVehicleTypeRequirements(self) 3912 3913 def HasTemporalTypeRequirements(self) -> "bool": 3914 return _pywrapcp.RoutingModel_HasTemporalTypeRequirements(self) 3915 3916 def HasTypeRegulations(self) -> "bool": 3917 r""" Returns true iff the model has any incompatibilities or requirements set on node types.""" 3918 return _pywrapcp.RoutingModel_HasTypeRegulations(self) 3919 3920 def UnperformedPenalty(self, var_index: "int64_t") -> "int64_t": 3921 r""" Get the "unperformed" penalty of a node. This is only well defined if the node is only part of a single Disjunction, and that disjunction has a penalty. For forced active nodes returns max int64_t. In all other cases, this returns 0.""" 3922 return _pywrapcp.RoutingModel_UnperformedPenalty(self, var_index) 3923 3924 def UnperformedPenaltyOrValue(self, default_value: "int64_t", var_index: "int64_t") -> "int64_t": 3925 r""" Same as above except that it returns default_value instead of 0 when penalty is not well defined (default value is passed as first argument to simplify the usage of the method in a callback).""" 3926 return _pywrapcp.RoutingModel_UnperformedPenaltyOrValue(self, default_value, var_index) 3927 3928 def GetDepot(self) -> "int64_t": 3929 r""" Returns the variable index of the first starting or ending node of all routes. If all routes start and end at the same node (single depot), this is the node returned.""" 3930 return _pywrapcp.RoutingModel_GetDepot(self) 3931 3932 def SetMaximumNumberOfActiveVehicles(self, max_active_vehicles: "int") -> "void": 3933 r""" Constrains the maximum number of active vehicles, aka the number of vehicles which do not have an empty route. For instance, this can be used to limit the number of routes in the case where there are fewer drivers than vehicles and that the fleet of vehicle is heterogeneous.""" 3934 return _pywrapcp.RoutingModel_SetMaximumNumberOfActiveVehicles(self, max_active_vehicles) 3935 3936 def GetMaximumNumberOfActiveVehicles(self) -> "int": 3937 r""" Returns the maximum number of active vehicles.""" 3938 return _pywrapcp.RoutingModel_GetMaximumNumberOfActiveVehicles(self) 3939 3940 def SetArcCostEvaluatorOfAllVehicles(self, evaluator_index: "int") -> "void": 3941 r""" Sets the cost function of the model such that the cost of a segment of a route between node 'from' and 'to' is evaluator(from, to), whatever the route or vehicle performing the route.""" 3942 return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfAllVehicles(self, evaluator_index) 3943 3944 def SetArcCostEvaluatorOfVehicle(self, evaluator_index: "int", vehicle: "int") -> "void": 3945 r""" Sets the cost function for a given vehicle route.""" 3946 return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle) 3947 3948 def SetFixedCostOfAllVehicles(self, cost: "int64_t") -> "void": 3949 r""" Sets the fixed cost of all vehicle routes. It is equivalent to calling SetFixedCostOfVehicle on all vehicle routes.""" 3950 return _pywrapcp.RoutingModel_SetFixedCostOfAllVehicles(self, cost) 3951 3952 def SetFixedCostOfVehicle(self, cost: "int64_t", vehicle: "int") -> "void": 3953 r""" Sets the fixed cost of one vehicle route.""" 3954 return _pywrapcp.RoutingModel_SetFixedCostOfVehicle(self, cost, vehicle) 3955 3956 def GetFixedCostOfVehicle(self, vehicle: "int") -> "int64_t": 3957 r""" Returns the route fixed cost taken into account if the route of the vehicle is not empty, aka there's at least one node on the route other than the first and last nodes.""" 3958 return _pywrapcp.RoutingModel_GetFixedCostOfVehicle(self, vehicle) 3959 3960 def SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor: "int64_t", quadratic_cost_factor: "int64_t") -> "void": 3961 r""" The following methods set the linear and quadratic cost factors of vehicles (must be positive values). The default value of these parameters is zero for all vehicles. When set, the cost_ of the model will contain terms aiming at reducing the number of vehicles used in the model, by adding the following to the objective for every vehicle v: INDICATOR(v used in the model) * [linear_cost_factor_of_vehicle_[v] - quadratic_cost_factor_of_vehicle_[v]*(square of length of route v)] i.e. for every used vehicle, we add the linear factor as fixed cost, and subtract the square of the route length multiplied by the quadratic factor. This second term aims at making the routes as dense as possible. Sets the linear and quadratic cost factor of all vehicles.""" 3962 return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor) 3963 3964 def SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor: "int64_t", quadratic_cost_factor: "int64_t", vehicle: "int") -> "void": 3965 r""" Sets the linear and quadratic cost factor of the given vehicle.""" 3966 return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle) 3967 3968 def GetAmortizedLinearCostFactorOfVehicles(self) -> "std::vector< int64_t > const &": 3969 return _pywrapcp.RoutingModel_GetAmortizedLinearCostFactorOfVehicles(self) 3970 3971 def GetAmortizedQuadraticCostFactorOfVehicles(self) -> "std::vector< int64_t > const &": 3972 return _pywrapcp.RoutingModel_GetAmortizedQuadraticCostFactorOfVehicles(self) 3973 3974 def SetVehicleUsedWhenEmpty(self, is_used: "bool", vehicle: "int") -> "void": 3975 return _pywrapcp.RoutingModel_SetVehicleUsedWhenEmpty(self, is_used, vehicle) 3976 3977 def IsVehicleUsedWhenEmpty(self, vehicle: "int") -> "bool": 3978 return _pywrapcp.RoutingModel_IsVehicleUsedWhenEmpty(self, vehicle) 3979 3980 def SetFirstSolutionEvaluator(self, evaluator: "operations_research::Solver::IndexEvaluator2") -> "void": 3981 r""" Gets/sets the evaluator used during the search. Only relevant when RoutingSearchParameters.first_solution_strategy = EVALUATOR_STRATEGY. Takes ownership of evaluator.""" 3982 return _pywrapcp.RoutingModel_SetFirstSolutionEvaluator(self, evaluator) 3983 3984 def AddLocalSearchOperator(self, ls_operator: "LocalSearchOperator") -> "void": 3985 r""" Adds a local search operator to the set of operators used to solve the vehicle routing problem.""" 3986 return _pywrapcp.RoutingModel_AddLocalSearchOperator(self, ls_operator) 3987 3988 def AddSearchMonitor(self, monitor: "SearchMonitor") -> "void": 3989 r""" Adds a search monitor to the search used to solve the routing model.""" 3990 return _pywrapcp.RoutingModel_AddSearchMonitor(self, monitor) 3991 3992 def AddAtSolutionCallback(self, callback: "std::function< void () >") -> "void": 3993 r""" Adds a callback called each time a solution is found during the search. This is a shortcut to creating a monitor to call the callback on AtSolution() and adding it with AddSearchMonitor.""" 3994 return _pywrapcp.RoutingModel_AddAtSolutionCallback(self, callback) 3995 3996 def AddVariableMinimizedByFinalizer(self, var: "IntVar") -> "void": 3997 r""" Adds a variable to minimize in the solution finalizer. The solution finalizer is called each time a solution is found during the search and allows to instantiate secondary variables (such as dimension cumul variables).""" 3998 return _pywrapcp.RoutingModel_AddVariableMinimizedByFinalizer(self, var) 3999 4000 def AddVariableMaximizedByFinalizer(self, var: "IntVar") -> "void": 4001 r""" Adds a variable to maximize in the solution finalizer (see above for information on the solution finalizer).""" 4002 return _pywrapcp.RoutingModel_AddVariableMaximizedByFinalizer(self, var) 4003 4004 def AddWeightedVariableMinimizedByFinalizer(self, var: "IntVar", cost: "int64_t") -> "void": 4005 r""" Adds a variable to minimize in the solution finalizer, with a weighted priority: the higher the more priority it has.""" 4006 return _pywrapcp.RoutingModel_AddWeightedVariableMinimizedByFinalizer(self, var, cost) 4007 4008 def AddWeightedVariableMaximizedByFinalizer(self, var: "IntVar", cost: "int64_t") -> "void": 4009 r""" Adds a variable to maximize in the solution finalizer, with a weighted priority: the higher the more priority it has.""" 4010 return _pywrapcp.RoutingModel_AddWeightedVariableMaximizedByFinalizer(self, var, cost) 4011 4012 def AddVariableTargetToFinalizer(self, var: "IntVar", target: "int64_t") -> "void": 4013 r""" Add a variable to set the closest possible to the target value in the solution finalizer.""" 4014 return _pywrapcp.RoutingModel_AddVariableTargetToFinalizer(self, var, target) 4015 4016 def AddWeightedVariableTargetToFinalizer(self, var: "IntVar", target: "int64_t", cost: "int64_t") -> "void": 4017 r""" Same as above with a weighted priority: the higher the cost, the more priority it has to be set close to the target value.""" 4018 return _pywrapcp.RoutingModel_AddWeightedVariableTargetToFinalizer(self, var, target, cost) 4019 4020 def CloseModel(self) -> "void": 4021 r""" Closes the current routing model; after this method is called, no modification to the model can be done, but RoutesToAssignment becomes available. Note that CloseModel() is automatically called by Solve() and other methods that produce solution. This is equivalent to calling CloseModelWithParameters(DefaultRoutingSearchParameters()).""" 4022 return _pywrapcp.RoutingModel_CloseModel(self) 4023 4024 def CloseModelWithParameters(self, search_parameters: "operations_research::RoutingSearchParameters const &") -> "void": 4025 r""" Same as above taking search parameters (as of 10/2015 some the parameters have to be set when closing the model).""" 4026 return _pywrapcp.RoutingModel_CloseModelWithParameters(self, search_parameters) 4027 4028 def Solve(self, assignment: "Assignment"=None) -> "operations_research::Assignment const *": 4029 r""" Solves the current routing model; closes the current model. This is equivalent to calling SolveWithParameters(DefaultRoutingSearchParameters()) or SolveFromAssignmentWithParameters(assignment, DefaultRoutingSearchParameters()).""" 4030 return _pywrapcp.RoutingModel_Solve(self, assignment) 4031 4032 def SolveWithParameters(self, search_parameters: "operations_research::RoutingSearchParameters const &", solutions: "std::vector< operations_research::Assignment const * > *"=None) -> "operations_research::Assignment const *": 4033 r""" Solves the current routing model with the given parameters. If 'solutions' is specified, it will contain the k best solutions found during the search (from worst to best, including the one returned by this method), where k corresponds to the 'number_of_solutions_to_collect' in 'search_parameters'. Note that the Assignment returned by the method and the ones in solutions are owned by the underlying solver and should not be deleted.""" 4034 return _pywrapcp.RoutingModel_SolveWithParameters(self, search_parameters, solutions) 4035 4036 def SolveFromAssignmentWithParameters(self, assignment: "Assignment", search_parameters: "operations_research::RoutingSearchParameters const &", solutions: "std::vector< operations_research::Assignment const * > *"=None) -> "operations_research::Assignment const *": 4037 r""" Same as above, except that if assignment is not null, it will be used as the initial solution.""" 4038 return _pywrapcp.RoutingModel_SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions) 4039 4040 def SolveFromAssignmentsWithParameters(self, assignments: "std::vector< operations_research::Assignment const * > const &", search_parameters: "operations_research::RoutingSearchParameters const &", solutions: "std::vector< operations_research::Assignment const * > *"=None) -> "operations_research::Assignment const *": 4041 r""" Same as above but will try all assignments in order as first solutions until one succeeds.""" 4042 return _pywrapcp.RoutingModel_SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions) 4043 4044 def SetAssignmentFromOtherModelAssignment(self, target_assignment: "Assignment", source_model: "RoutingModel", source_assignment: "Assignment") -> "void": 4045 r""" Given a "source_model" and its "source_assignment", resets "target_assignment" with the IntVar variables (nexts_, and vehicle_vars_ if costs aren't homogeneous across vehicles) of "this" model, with the values set according to those in "other_assignment". The objective_element of target_assignment is set to this->cost_.""" 4046 return _pywrapcp.RoutingModel_SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment) 4047 4048 def ComputeLowerBound(self) -> "int64_t": 4049 r""" Computes a lower bound to the routing problem solving a linear assignment problem. The routing model must be closed before calling this method. Note that problems with node disjunction constraints (including optional nodes) and non-homogenous costs are not supported (the method returns 0 in these cases).""" 4050 return _pywrapcp.RoutingModel_ComputeLowerBound(self) 4051 4052 def status(self) -> "operations_research::RoutingModel::Status": 4053 r""" Returns the current status of the routing model.""" 4054 return _pywrapcp.RoutingModel_status(self) 4055 4056 def enable_deep_serialization(self) -> "bool": 4057 r""" Returns the value of the internal enable_deep_serialization_ parameter.""" 4058 return _pywrapcp.RoutingModel_enable_deep_serialization(self) 4059 4060 def ApplyLocks(self, locks: "std::vector< int64_t > const &") -> "operations_research::IntVar *": 4061 r""" Applies a lock chain to the next search. 'locks' represents an ordered vector of nodes representing a partial route which will be fixed during the next search; it will constrain next variables such that: next[locks[i]] == locks[i+1]. Returns the next variable at the end of the locked chain; this variable is not locked. An assignment containing the locks can be obtained by calling PreAssignment().""" 4062 return _pywrapcp.RoutingModel_ApplyLocks(self, locks) 4063 4064 def ApplyLocksToAllVehicles(self, locks: "std::vector< std::vector< int64_t > > const &", close_routes: "bool") -> "bool": 4065 r""" Applies lock chains to all vehicles to the next search, such that locks[p] is the lock chain for route p. Returns false if the locks do not contain valid routes; expects that the routes do not contain the depots, i.e. there are empty vectors in place of empty routes. If close_routes is set to true, adds the end nodes to the route of each vehicle and deactivates other nodes. An assignment containing the locks can be obtained by calling PreAssignment().""" 4066 return _pywrapcp.RoutingModel_ApplyLocksToAllVehicles(self, locks, close_routes) 4067 4068 def PreAssignment(self) -> "operations_research::Assignment const *const": 4069 r""" Returns an assignment used to fix some of the variables of the problem. In practice, this assignment locks partial routes of the problem. This can be used in the context of locking the parts of the routes which have already been driven in online routing problems.""" 4070 return _pywrapcp.RoutingModel_PreAssignment(self) 4071 4072 def MutablePreAssignment(self) -> "operations_research::Assignment *": 4073 return _pywrapcp.RoutingModel_MutablePreAssignment(self) 4074 4075 def WriteAssignment(self, file_name: "std::string const &") -> "bool": 4076 r""" Writes the current solution to a file containing an AssignmentProto. Returns false if the file cannot be opened or if there is no current solution.""" 4077 return _pywrapcp.RoutingModel_WriteAssignment(self, file_name) 4078 4079 def ReadAssignment(self, file_name: "std::string const &") -> "operations_research::Assignment *": 4080 r""" Reads an assignment from a file and returns the current solution. Returns nullptr if the file cannot be opened or if the assignment is not valid.""" 4081 return _pywrapcp.RoutingModel_ReadAssignment(self, file_name) 4082 4083 def RestoreAssignment(self, solution: "Assignment") -> "operations_research::Assignment *": 4084 r""" Restores an assignment as a solution in the routing model and returns the new solution. Returns nullptr if the assignment is not valid.""" 4085 return _pywrapcp.RoutingModel_RestoreAssignment(self, solution) 4086 4087 def ReadAssignmentFromRoutes(self, routes: "std::vector< std::vector< int64_t > > const &", ignore_inactive_indices: "bool") -> "operations_research::Assignment *": 4088 r""" Restores the routes as the current solution. Returns nullptr if the solution cannot be restored (routes do not contain a valid solution). Note that calling this method will run the solver to assign values to the dimension variables; this may take considerable amount of time, especially when using dimensions with slack.""" 4089 return _pywrapcp.RoutingModel_ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices) 4090 4091 def RoutesToAssignment(self, routes: "std::vector< std::vector< int64_t > > const &", ignore_inactive_indices: "bool", close_routes: "bool", assignment: "Assignment") -> "bool": 4092 r""" Fills an assignment from a specification of the routes of the vehicles. The routes are specified as lists of variable indices that appear on the routes of the vehicles. The indices of the outer vector in 'routes' correspond to vehicles IDs, the inner vector contains the variable indices on the routes for the given vehicle. The inner vectors must not contain the start and end indices, as these are determined by the routing model. Sets the value of NextVars in the assignment, adding the variables to the assignment if necessary. The method does not touch other variables in the assignment. The method can only be called after the model is closed. With ignore_inactive_indices set to false, this method will fail (return nullptr) in case some of the route contain indices that are deactivated in the model; when set to true, these indices will be skipped. Returns true if routes were successfully loaded. However, such assignment still might not be a valid solution to the routing problem due to more complex constraints; it is advisible to call solver()->CheckSolution() afterwards.""" 4093 return _pywrapcp.RoutingModel_RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment) 4094 4095 def AssignmentToRoutes(self, assignment: "Assignment", routes: "std::vector< std::vector< int64_t > > *const") -> "void": 4096 r""" Converts the solution in the given assignment to routes for all vehicles. Expects that assignment contains a valid solution (i.e. routes for all vehicles end with an end index for that vehicle).""" 4097 return _pywrapcp.RoutingModel_AssignmentToRoutes(self, assignment, routes) 4098 4099 def CompactAssignment(self, assignment: "Assignment") -> "operations_research::Assignment *": 4100 r""" Converts the solution in the given assignment to routes for all vehicles. If the returned vector is route_indices, route_indices[i][j] is the index for jth location visited on route i. Note that contrary to AssignmentToRoutes, the vectors do include start and end locations. Returns a compacted version of the given assignment, in which all vehicles with id lower or equal to some N have non-empty routes, and all vehicles with id greater than N have empty routes. Does not take ownership of the returned object. If found, the cost of the compact assignment is the same as in the original assignment and it preserves the values of 'active' variables. Returns nullptr if a compact assignment was not found. This method only works in homogenous mode, and it only swaps equivalent vehicles (vehicles with the same start and end nodes). When creating the compact assignment, the empty plan is replaced by the route assigned to the compatible vehicle with the highest id. Note that with more complex constraints on vehicle variables, this method might fail even if a compact solution exists. This method changes the vehicle and dimension variables as necessary. While compacting the solution, only basic checks on vehicle variables are performed; if one of these checks fails no attempts to repair it are made (instead, the method returns nullptr).""" 4101 return _pywrapcp.RoutingModel_CompactAssignment(self, assignment) 4102 4103 def CompactAndCheckAssignment(self, assignment: "Assignment") -> "operations_research::Assignment *": 4104 r""" Same as CompactAssignment() but also checks the validity of the final compact solution; if it is not valid, no attempts to repair it are made (instead, the method returns nullptr).""" 4105 return _pywrapcp.RoutingModel_CompactAndCheckAssignment(self, assignment) 4106 4107 def AddToAssignment(self, var: "IntVar") -> "void": 4108 r""" Adds an extra variable to the vehicle routing assignment.""" 4109 return _pywrapcp.RoutingModel_AddToAssignment(self, var) 4110 4111 def AddIntervalToAssignment(self, interval: "IntervalVar") -> "void": 4112 return _pywrapcp.RoutingModel_AddIntervalToAssignment(self, interval) 4113 4114 def PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment: "Assignment", duration_limit: "absl::Duration", time_limit_was_reached: "bool *"=None) -> "operations_research::Assignment const *": 4115 r""" For every dimension in the model with an optimizer in local/global_dimension_optimizers_, this method tries to pack the cumul values of the dimension, such that: - The cumul costs (span costs, soft lower and upper bound costs, etc) are minimized. - The cumuls of the ends of the routes are minimized for this given minimal cumul cost. - Given these minimal end cumuls, the route start cumuls are maximized. Returns the assignment resulting from allocating these packed cumuls with the solver, and nullptr if these cumuls could not be set by the solver.""" 4116 return _pywrapcp.RoutingModel_PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached) 4117 4118 def AddLocalSearchFilter(self, filter: "LocalSearchFilter") -> "void": 4119 r""" Adds a custom local search filter to the list of filters used to speed up local search by pruning unfeasible variable assignments. Calling this method after the routing model has been closed (CloseModel() or Solve() has been called) has no effect. The routing model does not take ownership of the filter.""" 4120 return _pywrapcp.RoutingModel_AddLocalSearchFilter(self, filter) 4121 4122 def Start(self, vehicle: "int") -> "int64_t": 4123 r""" Model inspection. Returns the variable index of the starting node of a vehicle route.""" 4124 return _pywrapcp.RoutingModel_Start(self, vehicle) 4125 4126 def End(self, vehicle: "int") -> "int64_t": 4127 r""" Returns the variable index of the ending node of a vehicle route.""" 4128 return _pywrapcp.RoutingModel_End(self, vehicle) 4129 4130 def IsStart(self, index: "int64_t") -> "bool": 4131 r""" Returns true if 'index' represents the first node of a route.""" 4132 return _pywrapcp.RoutingModel_IsStart(self, index) 4133 4134 def IsEnd(self, index: "int64_t") -> "bool": 4135 r""" Returns true if 'index' represents the last node of a route.""" 4136 return _pywrapcp.RoutingModel_IsEnd(self, index) 4137 4138 def VehicleIndex(self, index: "int64_t") -> "int": 4139 r""" Returns the vehicle of the given start/end index, and -1 if the given index is not a vehicle start/end.""" 4140 return _pywrapcp.RoutingModel_VehicleIndex(self, index) 4141 4142 def Next(self, assignment: "Assignment", index: "int64_t") -> "int64_t": 4143 r""" Assignment inspection Returns the variable index of the node directly after the node corresponding to 'index' in 'assignment'.""" 4144 return _pywrapcp.RoutingModel_Next(self, assignment, index) 4145 4146 def IsVehicleUsed(self, assignment: "Assignment", vehicle: "int") -> "bool": 4147 r""" Returns true if the route of 'vehicle' is non empty in 'assignment'.""" 4148 return _pywrapcp.RoutingModel_IsVehicleUsed(self, assignment, vehicle) 4149 4150 def NextVar(self, index: "int64_t") -> "operations_research::IntVar *": 4151 r""" Returns the next variable of the node corresponding to index. Note that NextVar(index) == index is equivalent to ActiveVar(index) == 0.""" 4152 return _pywrapcp.RoutingModel_NextVar(self, index) 4153 4154 def ActiveVar(self, index: "int64_t") -> "operations_research::IntVar *": 4155 r""" Returns the active variable of the node corresponding to index.""" 4156 return _pywrapcp.RoutingModel_ActiveVar(self, index) 4157 4158 def ActiveVehicleVar(self, vehicle: "int") -> "operations_research::IntVar *": 4159 r""" Returns the active variable of the vehicle. It will be equal to 1 iff the route of the vehicle is not empty, 0 otherwise.""" 4160 return _pywrapcp.RoutingModel_ActiveVehicleVar(self, vehicle) 4161 4162 def VehicleRouteConsideredVar(self, vehicle: "int") -> "operations_research::IntVar *": 4163 r""" Returns the variable specifying whether or not the given vehicle route is considered for costs and constraints. It will be equal to 1 iff the route of the vehicle is not empty OR vehicle_used_when_empty_[vehicle] is true.""" 4164 return _pywrapcp.RoutingModel_VehicleRouteConsideredVar(self, vehicle) 4165 4166 def VehicleVar(self, index: "int64_t") -> "operations_research::IntVar *": 4167 r""" Returns the vehicle variable of the node corresponding to index. Note that VehicleVar(index) == -1 is equivalent to ActiveVar(index) == 0.""" 4168 return _pywrapcp.RoutingModel_VehicleVar(self, index) 4169 4170 def ResourceVar(self, vehicle: "int", resource_group: "int") -> "operations_research::IntVar *": 4171 r""" Returns the resource variable for the given vehicle index in the given resource group. If a vehicle doesn't require a resource from the corresponding resource group, then ResourceVar(v, r_g) == -1.""" 4172 return _pywrapcp.RoutingModel_ResourceVar(self, vehicle, resource_group) 4173 4174 def CostVar(self) -> "operations_research::IntVar *": 4175 r""" Returns the global cost variable which is being minimized.""" 4176 return _pywrapcp.RoutingModel_CostVar(self) 4177 4178 def GetArcCostForVehicle(self, from_index: "int64_t", to_index: "int64_t", vehicle: "int64_t") -> "int64_t": 4179 r""" Returns the cost of the transit arc between two nodes for a given vehicle. Input are variable indices of node. This returns 0 if vehicle < 0.""" 4180 return _pywrapcp.RoutingModel_GetArcCostForVehicle(self, from_index, to_index, vehicle) 4181 4182 def CostsAreHomogeneousAcrossVehicles(self) -> "bool": 4183 r""" Whether costs are homogeneous across all vehicles.""" 4184 return _pywrapcp.RoutingModel_CostsAreHomogeneousAcrossVehicles(self) 4185 4186 def GetHomogeneousCost(self, from_index: "int64_t", to_index: "int64_t") -> "int64_t": 4187 r""" Returns the cost of the segment between two nodes supposing all vehicle costs are the same (returns the cost for the first vehicle otherwise).""" 4188 return _pywrapcp.RoutingModel_GetHomogeneousCost(self, from_index, to_index) 4189 4190 def GetArcCostForFirstSolution(self, from_index: "int64_t", to_index: "int64_t") -> "int64_t": 4191 r""" Returns the cost of the arc in the context of the first solution strategy. This is typically a simplification of the actual cost; see the .cc.""" 4192 return _pywrapcp.RoutingModel_GetArcCostForFirstSolution(self, from_index, to_index) 4193 4194 def GetArcCostForClass(self, from_index: "int64_t", to_index: "int64_t", cost_class_index: "int64_t") -> "int64_t": 4195 r""" Returns the cost of the segment between two nodes for a given cost class. Input are variable indices of nodes and the cost class. Unlike GetArcCostForVehicle(), if cost_class is kNoCost, then the returned cost won't necessarily be zero: only some of the components of the cost that depend on the cost class will be omited. See the code for details.""" 4196 return _pywrapcp.RoutingModel_GetArcCostForClass(self, from_index, to_index, cost_class_index) 4197 4198 def GetCostClassIndexOfVehicle(self, vehicle: "int64_t") -> "operations_research::RoutingModel::CostClassIndex": 4199 r""" Get the cost class index of the given vehicle.""" 4200 return _pywrapcp.RoutingModel_GetCostClassIndexOfVehicle(self, vehicle) 4201 4202 def HasVehicleWithCostClassIndex(self, cost_class_index: "operations_research::RoutingModel::CostClassIndex") -> "bool": 4203 r""" Returns true iff the model contains a vehicle with the given cost_class_index.""" 4204 return _pywrapcp.RoutingModel_HasVehicleWithCostClassIndex(self, cost_class_index) 4205 4206 def GetCostClassesCount(self) -> "int": 4207 r""" Returns the number of different cost classes in the model.""" 4208 return _pywrapcp.RoutingModel_GetCostClassesCount(self) 4209 4210 def GetNonZeroCostClassesCount(self) -> "int": 4211 r""" Ditto, minus the 'always zero', built-in cost class.""" 4212 return _pywrapcp.RoutingModel_GetNonZeroCostClassesCount(self) 4213 4214 def GetVehicleClassIndexOfVehicle(self, vehicle: "int64_t") -> "operations_research::RoutingModel::VehicleClassIndex": 4215 return _pywrapcp.RoutingModel_GetVehicleClassIndexOfVehicle(self, vehicle) 4216 4217 def GetVehicleOfClass(self, vehicle_class: "operations_research::RoutingModel::VehicleClassIndex") -> "int": 4218 r""" Returns a vehicle of the given vehicle class, and -1 if there are no vehicles for this class.""" 4219 return _pywrapcp.RoutingModel_GetVehicleOfClass(self, vehicle_class) 4220 4221 def GetVehicleClassesCount(self) -> "int": 4222 r""" Returns the number of different vehicle classes in the model.""" 4223 return _pywrapcp.RoutingModel_GetVehicleClassesCount(self) 4224 4225 def GetSameVehicleIndicesOfIndex(self, node: "int") -> "std::vector< int > const &": 4226 r""" Returns variable indices of nodes constrained to be on the same route.""" 4227 return _pywrapcp.RoutingModel_GetSameVehicleIndicesOfIndex(self, node) 4228 4229 def GetVehicleTypeContainer(self) -> "operations_research::RoutingModel::VehicleTypeContainer const &": 4230 return _pywrapcp.RoutingModel_GetVehicleTypeContainer(self) 4231 4232 def ArcIsMoreConstrainedThanArc(self, _from: "int64_t", to1: "int64_t", to2: "int64_t") -> "bool": 4233 r""" Returns whether the arc from->to1 is more constrained than from->to2, taking into account, in order: - whether the destination node isn't an end node - whether the destination node is mandatory - whether the destination node is bound to the same vehicle as the source - the "primary constrained" dimension (see SetPrimaryConstrainedDimension) It then breaks ties using, in order: - the arc cost (taking unperformed penalties into account) - the size of the vehicle vars of "to1" and "to2" (lowest size wins) - the value: the lowest value of the indices to1 and to2 wins. See the .cc for details. The more constrained arc is typically preferable when building a first solution. This method is intended to be used as a callback for the BestValueByComparisonSelector value selector. Args: from: the variable index of the source node to1: the variable index of the first candidate destination node. to2: the variable index of the second candidate destination node.""" 4234 return _pywrapcp.RoutingModel_ArcIsMoreConstrainedThanArc(self, _from, to1, to2) 4235 4236 def DebugOutputAssignment(self, solution_assignment: "Assignment", dimension_to_print: "std::string const &") -> "std::string": 4237 r""" Print some debugging information about an assignment, including the feasible intervals of the CumulVar for dimension "dimension_to_print" at each step of the routes. If "dimension_to_print" is omitted, all dimensions will be printed.""" 4238 return _pywrapcp.RoutingModel_DebugOutputAssignment(self, solution_assignment, dimension_to_print) 4239 4240 def solver(self) -> "operations_research::Solver *": 4241 r""" Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair containing the minimum and maximum of the CumulVar of the jth node on route i. - cumul_bounds[i][j].first is the minimum. - cumul_bounds[i][j].second is the maximum. Returns the underlying constraint solver. Can be used to add extra constraints and/or modify search algorithms.""" 4242 return _pywrapcp.RoutingModel_solver(self) 4243 4244 def CheckLimit(self) -> "bool": 4245 r""" Returns true if the search limit has been crossed.""" 4246 return _pywrapcp.RoutingModel_CheckLimit(self) 4247 4248 def RemainingTime(self) -> "absl::Duration": 4249 r""" Returns the time left in the search limit.""" 4250 return _pywrapcp.RoutingModel_RemainingTime(self) 4251 4252 def nodes(self) -> "int": 4253 r""" Sizes and indices Returns the number of nodes in the model.""" 4254 return _pywrapcp.RoutingModel_nodes(self) 4255 4256 def vehicles(self) -> "int": 4257 r""" Returns the number of vehicle routes in the model.""" 4258 return _pywrapcp.RoutingModel_vehicles(self) 4259 4260 def Size(self) -> "int64_t": 4261 r""" Returns the number of next variables in the model.""" 4262 return _pywrapcp.RoutingModel_Size(self) 4263 4264 def GetNumberOfDecisionsInFirstSolution(self, search_parameters: "operations_research::RoutingSearchParameters const &") -> "int64_t": 4265 r""" Returns statistics on first solution search, number of decisions sent to filters, number of decisions rejected by filters.""" 4266 return _pywrapcp.RoutingModel_GetNumberOfDecisionsInFirstSolution(self, search_parameters) 4267 4268 def GetNumberOfRejectsInFirstSolution(self, search_parameters: "operations_research::RoutingSearchParameters const &") -> "int64_t": 4269 return _pywrapcp.RoutingModel_GetNumberOfRejectsInFirstSolution(self, search_parameters) 4270 4271 def GetAutomaticFirstSolutionStrategy(self) -> "operations_research::FirstSolutionStrategy::Value": 4272 r""" Returns the automatic first solution strategy selected.""" 4273 return _pywrapcp.RoutingModel_GetAutomaticFirstSolutionStrategy(self) 4274 4275 def IsMatchingModel(self) -> "bool": 4276 r""" Returns true if a vehicle/node matching problem is detected.""" 4277 return _pywrapcp.RoutingModel_IsMatchingModel(self) 4278 4279 def AreRoutesInterdependent(self, parameters: "operations_research::RoutingSearchParameters const &") -> "bool": 4280 r""" Returns true if routes are interdependent. This means that any modification to a route might impact another.""" 4281 return _pywrapcp.RoutingModel_AreRoutesInterdependent(self, parameters) 4282 4283 def MakeGuidedSlackFinalizer(self, dimension: "RoutingDimension", initializer: "std::function< int64_t (int64_t) >") -> "operations_research::DecisionBuilder *": 4284 r""" The next few members are in the public section only for testing purposes. MakeGuidedSlackFinalizer creates a DecisionBuilder for the slacks of a dimension using a callback to choose which values to start with. The finalizer works only when all next variables in the model have been fixed. It has the following two characteristics: 1. It follows the routes defined by the nexts variables when choosing a variable to make a decision on. 2. When it comes to choose a value for the slack of node i, the decision builder first calls the callback with argument i, and supposingly the returned value is x it creates decisions slack[i] = x, slack[i] = x + 1, slack[i] = x - 1, slack[i] = x + 2, etc.""" 4285 return _pywrapcp.RoutingModel_MakeGuidedSlackFinalizer(self, dimension, initializer) 4286 4287 def MakeSelfDependentDimensionFinalizer(self, dimension: "RoutingDimension") -> "operations_research::DecisionBuilder *": 4288 r""" MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a self-dependent dimension. It makes an extensive use of the caches of the state dependent transits. In detail, MakeSelfDependentDimensionFinalizer returns a composition of a local search decision builder with a greedy descent operator for the cumul of the start of each route and a guided slack finalizer. Provided there are no time windows and the maximum slacks are large enough, once the cumul of the start of route is fixed, the guided finalizer can find optimal values of the slacks for the rest of the route in time proportional to the length of the route. Therefore the composed finalizer generally works in time O(log(t)*n*m), where t is the latest possible departute time, n is the number of nodes in the network and m is the number of vehicles.""" 4289 return _pywrapcp.RoutingModel_MakeSelfDependentDimensionFinalizer(self, dimension)
3622 def RegisterUnaryTransitVector(self, values: "std::vector< int64_t >") -> "int": 3623 r""" Registers 'callback' and returns its index.""" 3624 return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values)
Registers 'callback' and returns its index.
3647 def AddDimension(self, evaluator_index: "int", slack_max: "int64_t", capacity: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "bool": 3648 r""" Model creation Methods to add dimensions to routes; dimensions represent quantities accumulated at nodes along the routes. They represent quantities such as weights or volumes carried along the route, or distance or times. Quantities at a node are represented by "cumul" variables and the increase or decrease of quantities between nodes are represented by "transit" variables. These variables are linked as follows: if j == next(i), cumul(j) = cumul(i) + transit(i) + slack(i) where slack is a positive slack variable (can represent waiting times for a time dimension). Setting the value of fix_start_cumul_to_zero to true will force the "cumul" variable of the start node of all vehicles to be equal to 0. Creates a dimension where the transit variable is constrained to be equal to evaluator(i, next(i)); 'slack_max' is the upper bound of the slack variable and 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns false if a dimension with the same name has already been created (and doesn't create the new dimension). Takes ownership of the callback 'evaluator'.""" 3649 return _pywrapcp.RoutingModel_AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name)
Model creation Methods to add dimensions to routes; dimensions represent quantities accumulated at nodes along the routes. They represent quantities such as weights or volumes carried along the route, or distance or times. Quantities at a node are represented by "cumul" variables and the increase or decrease of quantities between nodes are represented by "transit" variables. These variables are linked as follows: if j == next(i), cumul(j) = cumul(i) + transit(i) + slack(i) where slack is a positive slack variable (can represent waiting times for a time dimension). Setting the value of fix_start_cumul_to_zero to true will force the "cumul" variable of the start node of all vehicles to be equal to 0. Creates a dimension where the transit variable is constrained to be equal to evaluator(i, next(i)); 'slack_max' is the upper bound of the slack variable and 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns false if a dimension with the same name has already been created (and doesn't create the new dimension). Takes ownership of the callback 'evaluator'.
3651 def AddDimensionWithVehicleTransits(self, evaluator_indices: "std::vector< int > const &", slack_max: "int64_t", capacity: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "bool": 3652 return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name)
3654 def AddDimensionWithVehicleCapacity(self, evaluator_index: "int", slack_max: "int64_t", vehicle_capacities: "std::vector< int64_t >", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "bool": 3655 return _pywrapcp.RoutingModel_AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
3657 def AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices: "std::vector< int > const &", slack_max: "int64_t", vehicle_capacities: "std::vector< int64_t >", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "bool": 3658 return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
3660 def AddConstantDimensionWithSlack(self, value: "int64_t", capacity: "int64_t", slack_max: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >": 3661 r""" Creates a dimension where the transit variable is constrained to be equal to 'value'; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered unary transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).""" 3662 return _pywrapcp.RoutingModel_AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name)
Creates a dimension where the transit variable is constrained to be equal to 'value'; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered unary transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).
3667 def AddVectorDimension(self, values: "std::vector< int64_t >", capacity: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >": 3668 r""" Creates a dimension where the transit variable is constrained to be equal to 'values[i]' for node i; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered unary transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).""" 3669 return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name)
Creates a dimension where the transit variable is constrained to be equal to 'values[i]' for node i; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered unary transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).
3671 def AddMatrixDimension(self, values: "std::vector< std::vector< int64_t > >", capacity: "int64_t", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >": 3672 r""" Creates a dimension where the transit variable is constrained to be equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).""" 3673 return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name)
Creates a dimension where the transit variable is constrained to be equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).
3675 def MakePathSpansAndTotalSlacks(self, dimension: "RoutingDimension", spans: "std::vector< operations_research::IntVar * >", total_slacks: "std::vector< operations_research::IntVar * >") -> "operations_research::Constraint *": 3676 r""" For every vehicle of the routing model: - if total_slacks[vehicle] is not nullptr, constrains it to be the sum of slacks on that vehicle, that is, dimension->CumulVar(end) - dimension->CumulVar(start) - sum_{node in path of vehicle} dimension->FixedTransitVar(node). - if spans[vehicle] is not nullptr, constrains it to be dimension->CumulVar(end) - dimension->CumulVar(start) This does stronger propagation than a decomposition, and takes breaks into account.""" 3677 return _pywrapcp.RoutingModel_MakePathSpansAndTotalSlacks(self, dimension, spans, total_slacks)
For every vehicle of the routing model: - if total_slacks[vehicle] is not nullptr, constrains it to be the sum of slacks on that vehicle, that is, dimension->CumulVar(end) - dimension->CumulVar(start) - sum_{node in path of vehicle} dimension->FixedTransitVar(node). - if spans[vehicle] is not nullptr, constrains it to be dimension->CumulVar(end) - dimension->CumulVar(start) This does stronger propagation than a decomposition, and takes breaks into account.
3679 def GetAllDimensionNames(self) -> "std::vector< std::string >": 3680 r""" Outputs the names of all dimensions added to the routing engine.""" 3681 return _pywrapcp.RoutingModel_GetAllDimensionNames(self)
Outputs the names of all dimensions added to the routing engine.
3683 def GetDimensions(self) -> "std::vector< operations_research::RoutingDimension * > const &": 3684 r""" Returns all dimensions of the model.""" 3685 return _pywrapcp.RoutingModel_GetDimensions(self)
Returns all dimensions of the model.
3687 def GetDimensionsWithSoftOrSpanCosts(self) -> "std::vector< operations_research::RoutingDimension * >": 3688 r""" Returns dimensions with soft or vehicle span costs.""" 3689 return _pywrapcp.RoutingModel_GetDimensionsWithSoftOrSpanCosts(self)
Returns dimensions with soft or vehicle span costs.
3691 def GetDimensionsWithGlobalCumulOptimizers(self) -> "std::vector< operations_research::RoutingDimension const * >": 3692 r""" Returns the dimensions which have [global|local]_dimension_optimizers_.""" 3693 return _pywrapcp.RoutingModel_GetDimensionsWithGlobalCumulOptimizers(self)
Returns the dimensions which have [global|local]_dimension_optimizers_.
3698 def HasGlobalCumulOptimizer(self, dimension: "RoutingDimension") -> "bool": 3699 r""" Returns whether the given dimension has global/local cumul optimizers.""" 3700 return _pywrapcp.RoutingModel_HasGlobalCumulOptimizer(self, dimension)
Returns whether the given dimension has global/local cumul optimizers.
3705 def GetMutableGlobalCumulLPOptimizer(self, dimension: "RoutingDimension") -> "operations_research::GlobalDimensionCumulOptimizer *": 3706 r""" Returns the global/local dimension cumul optimizer for a given dimension, or nullptr if there is none.""" 3707 return _pywrapcp.RoutingModel_GetMutableGlobalCumulLPOptimizer(self, dimension)
Returns the global/local dimension cumul optimizer for a given dimension, or nullptr if there is none.
3718 def HasDimension(self, dimension_name: "std::string const &") -> "bool": 3719 r""" Returns true if a dimension exists for a given dimension name.""" 3720 return _pywrapcp.RoutingModel_HasDimension(self, dimension_name)
Returns true if a dimension exists for a given dimension name.
3722 def GetDimensionOrDie(self, dimension_name: "std::string const &") -> "operations_research::RoutingDimension const &": 3723 r""" Returns a dimension from its name. Dies if the dimension does not exist.""" 3724 return _pywrapcp.RoutingModel_GetDimensionOrDie(self, dimension_name)
Returns a dimension from its name. Dies if the dimension does not exist.
3726 def GetMutableDimension(self, dimension_name: "std::string const &") -> "operations_research::RoutingDimension *": 3727 r""" Returns a dimension from its name. Returns nullptr if the dimension does not exist.""" 3728 return _pywrapcp.RoutingModel_GetMutableDimension(self, dimension_name)
Returns a dimension from its name. Returns nullptr if the dimension does not exist.
3730 def SetPrimaryConstrainedDimension(self, dimension_name: "std::string const &") -> "void": 3731 r""" Set the given dimension as "primary constrained". As of August 2013, this is only used by ArcIsMoreConstrainedThanArc(). "dimension" must be the name of an existing dimension, or be empty, in which case there will not be a primary dimension after this call.""" 3732 return _pywrapcp.RoutingModel_SetPrimaryConstrainedDimension(self, dimension_name)
Set the given dimension as "primary constrained". As of August 2013, this is only used by ArcIsMoreConstrainedThanArc(). "dimension" must be the name of an existing dimension, or be empty, in which case there will not be a primary dimension after this call.
3734 def GetPrimaryConstrainedDimension(self) -> "std::string const &": 3735 r""" Get the primary constrained dimension, or an empty string if it is unset.""" 3736 return _pywrapcp.RoutingModel_GetPrimaryConstrainedDimension(self)
Get the primary constrained dimension, or an empty string if it is unset.
3738 def AddResourceGroup(self) -> "int": 3739 r""" Adds a resource group to the routing model. Returns its index in resource_groups_.""" 3740 return _pywrapcp.RoutingModel_AddResourceGroup(self)
Adds a resource group to the routing model. Returns its index in resource_groups_.
3748 def GetDimensionResourceGroupIndices(self, dimension: "RoutingDimension") -> "std::vector< int > const &": 3749 r""" Returns the indices of resource groups for this dimension. This method can only be called after the model has been closed.""" 3750 return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndices(self, dimension)
Returns the indices of resource groups for this dimension. This method can only be called after the model has been closed.
3752 def GetDimensionResourceGroupIndex(self, dimension: "RoutingDimension") -> "int": 3753 r""" Returns the index of the resource group attached to the dimension. DCHECKS that there's exactly one resource group for this dimension.""" 3754 return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndex(self, dimension)
Returns the index of the resource group attached to the dimension. DCHECKS that there's exactly one resource group for this dimension.
3756 def AddDisjunction(self, *args) -> "operations_research::RoutingModel::DisjunctionIndex": 3757 r""" Adds a disjunction constraint on the indices: exactly 'max_cardinality' of the indices are active. Start and end indices of any vehicle cannot be part of a disjunction. If a penalty is given, at most 'max_cardinality' of the indices can be active, and if less are active, 'penalty' is payed per inactive index. This is equivalent to adding the constraint: p + Sum(i)active[i] == max_cardinality where p is an integer variable, and the following cost to the cost function: p * penalty. 'penalty' must be positive to make the disjunction optional; a negative penalty will force 'max_cardinality' indices of the disjunction to be performed, and therefore p == 0. Note: passing a vector with a single index will model an optional index with a penalty cost if it is not visited.""" 3758 return _pywrapcp.RoutingModel_AddDisjunction(self, *args)
Adds a disjunction constraint on the indices: exactly 'max_cardinality' of the indices are active. Start and end indices of any vehicle cannot be part of a disjunction. If a penalty is given, at most 'max_cardinality' of the indices can be active, and if less are active, 'penalty' is payed per inactive index. This is equivalent to adding the constraint: p + Sum(i)active[i] == max_cardinality where p is an integer variable, and the following cost to the cost function: p * penalty. 'penalty' must be positive to make the disjunction optional; a negative penalty will force 'max_cardinality' indices of the disjunction to be performed, and therefore p == 0. Note: passing a vector with a single index will model an optional index with a penalty cost if it is not visited.
3760 def GetDisjunctionIndices(self, index: "int64_t") -> "std::vector< operations_research::RoutingModel::DisjunctionIndex > const &": 3761 r""" Returns the indices of the disjunctions to which an index belongs.""" 3762 return _pywrapcp.RoutingModel_GetDisjunctionIndices(self, index)
Returns the indices of the disjunctions to which an index belongs.
3764 def GetDisjunctionPenalty(self, index: "operations_research::RoutingModel::DisjunctionIndex") -> "int64_t": 3765 r""" Returns the penalty of the node disjunction of index 'index'.""" 3766 return _pywrapcp.RoutingModel_GetDisjunctionPenalty(self, index)
Returns the penalty of the node disjunction of index 'index'.
3768 def GetDisjunctionMaxCardinality(self, index: "operations_research::RoutingModel::DisjunctionIndex") -> "int64_t": 3769 r""" Returns the maximum number of possible active nodes of the node disjunction of index 'index'.""" 3770 return _pywrapcp.RoutingModel_GetDisjunctionMaxCardinality(self, index)
Returns the maximum number of possible active nodes of the node disjunction of index 'index'.
3772 def GetNumberOfDisjunctions(self) -> "int": 3773 r""" Returns the number of node disjunctions in the model.""" 3774 return _pywrapcp.RoutingModel_GetNumberOfDisjunctions(self)
Returns the number of node disjunctions in the model.
3776 def HasMandatoryDisjunctions(self) -> "bool": 3777 r""" Returns true if the model contains mandatory disjunctions (ones with kNoPenalty as penalty).""" 3778 return _pywrapcp.RoutingModel_HasMandatoryDisjunctions(self)
Returns true if the model contains mandatory disjunctions (ones with kNoPenalty as penalty).
3780 def HasMaxCardinalityConstrainedDisjunctions(self) -> "bool": 3781 r""" Returns true if the model contains at least one disjunction which is constrained by its max_cardinality.""" 3782 return _pywrapcp.RoutingModel_HasMaxCardinalityConstrainedDisjunctions(self)
Returns true if the model contains at least one disjunction which is constrained by its max_cardinality.
3784 def GetPerfectBinaryDisjunctions(self) -> "std::vector< std::pair< int64_t,int64_t > >": 3785 r""" Returns the list of all perfect binary disjunctions, as pairs of variable indices: a disjunction is "perfect" when its variables do not appear in any other disjunction. Each pair is sorted (lowest variable index first), and the output vector is also sorted (lowest pairs first).""" 3786 return _pywrapcp.RoutingModel_GetPerfectBinaryDisjunctions(self)
Returns the list of all perfect binary disjunctions, as pairs of variable indices: a disjunction is "perfect" when its variables do not appear in any other disjunction. Each pair is sorted (lowest variable index first), and the output vector is also sorted (lowest pairs first).
3788 def IgnoreDisjunctionsAlreadyForcedToZero(self) -> "void": 3789 r""" SPECIAL: Makes the solver ignore all the disjunctions whose active variables are all trivially zero (i.e. Max() == 0), by setting their max_cardinality to 0. This can be useful when using the BaseBinaryDisjunctionNeighborhood operators, in the context of arc-based routing.""" 3790 return _pywrapcp.RoutingModel_IgnoreDisjunctionsAlreadyForcedToZero(self)
SPECIAL: Makes the solver ignore all the disjunctions whose active variables are all trivially zero (i.e. Max() == 0), by setting their max_cardinality to 0. This can be useful when using the BaseBinaryDisjunctionNeighborhood operators, in the context of arc-based routing.
3792 def AddSoftSameVehicleConstraint(self, indices: "std::vector< int64_t > const &", cost: "int64_t") -> "void": 3793 r""" Adds a soft constraint to force a set of variable indices to be on the same vehicle. If all nodes are not on the same vehicle, each extra vehicle used adds 'cost' to the cost function.""" 3794 return _pywrapcp.RoutingModel_AddSoftSameVehicleConstraint(self, indices, cost)
Adds a soft constraint to force a set of variable indices to be on the same vehicle. If all nodes are not on the same vehicle, each extra vehicle used adds 'cost' to the cost function.
3796 def SetAllowedVehiclesForIndex(self, vehicles: "std::vector< int > const &", index: "int64_t") -> "void": 3797 r""" Sets the vehicles which can visit a given node. If the node is in a disjunction, this will not prevent it from being unperformed. Specifying an empty vector of vehicles has no effect (all vehicles will be allowed to visit the node).""" 3798 return _pywrapcp.RoutingModel_SetAllowedVehiclesForIndex(self, vehicles, index)
Sets the vehicles which can visit a given node. If the node is in a disjunction, this will not prevent it from being unperformed. Specifying an empty vector of vehicles has no effect (all vehicles will be allowed to visit the node).
3800 def IsVehicleAllowedForIndex(self, vehicle: "int", index: "int64_t") -> "bool": 3801 r""" Returns true if a vehicle is allowed to visit a given node.""" 3802 return _pywrapcp.RoutingModel_IsVehicleAllowedForIndex(self, vehicle, index)
Returns true if a vehicle is allowed to visit a given node.
3804 def AddPickupAndDelivery(self, pickup: "int64_t", delivery: "int64_t") -> "void": 3805 r""" Notifies that index1 and index2 form a pair of nodes which should belong to the same route. This methods helps the search find better solutions, especially in the local search phase. It should be called each time you have an equality constraint linking the vehicle variables of two node (including for instance pickup and delivery problems): Solver* const solver = routing.solver(); int64_t index1 = manager.NodeToIndex(node1); int64_t index2 = manager.NodeToIndex(node2); solver->AddConstraint(solver->MakeEquality( routing.VehicleVar(index1), routing.VehicleVar(index2))); routing.AddPickupAndDelivery(index1, index2);""" 3806 return _pywrapcp.RoutingModel_AddPickupAndDelivery(self, pickup, delivery)
Notifies that index1 and index2 form a pair of nodes which should belong to the same route. This methods helps the search find better solutions, especially in the local search phase. It should be called each time you have an equality constraint linking the vehicle variables of two node (including for instance pickup and delivery problems): Solver* const solver = routing.solver(); int64_t index1 = manager.NodeToIndex(node1); int64_t index2 = manager.NodeToIndex(node2); solver->AddConstraint(solver->MakeEquality( routing.VehicleVar(index1), routing.VehicleVar(index2))); routing.AddPickupAndDelivery(index1, index2);
3808 def AddPickupAndDeliverySets(self, pickup_disjunction: "operations_research::RoutingModel::DisjunctionIndex", delivery_disjunction: "operations_research::RoutingModel::DisjunctionIndex") -> "void": 3809 r""" Same as AddPickupAndDelivery but notifying that the performed node from the disjunction of index 'pickup_disjunction' is on the same route as the performed node from the disjunction of index 'delivery_disjunction'.""" 3810 return _pywrapcp.RoutingModel_AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction)
Same as AddPickupAndDelivery but notifying that the performed node from the disjunction of index 'pickup_disjunction' is on the same route as the performed node from the disjunction of index 'delivery_disjunction'.
3812 def GetPickupIndexPairs(self, node_index: "int64_t") -> "std::vector< std::pair< int,int > > const &": 3813 r""" Returns pairs for which the node is a pickup; the first element of each pair is the index in the pickup and delivery pairs list in which the pickup appears, the second element is its index in the pickups list.""" 3814 return _pywrapcp.RoutingModel_GetPickupIndexPairs(self, node_index)
Returns pairs for which the node is a pickup; the first element of each pair is the index in the pickup and delivery pairs list in which the pickup appears, the second element is its index in the pickups list.
3816 def GetDeliveryIndexPairs(self, node_index: "int64_t") -> "std::vector< std::pair< int,int > > const &": 3817 r""" Same as above for deliveries.""" 3818 return _pywrapcp.RoutingModel_GetDeliveryIndexPairs(self, node_index)
Same as above for deliveries.
3820 def SetPickupAndDeliveryPolicyOfAllVehicles(self, policy: "operations_research::RoutingModel::PickupAndDeliveryPolicy") -> "void": 3821 r""" Sets the Pickup and delivery policy of all vehicles. It is equivalent to calling SetPickupAndDeliveryPolicyOfVehicle on all vehicles.""" 3822 return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfAllVehicles(self, policy)
Sets the Pickup and delivery policy of all vehicles. It is equivalent to calling SetPickupAndDeliveryPolicyOfVehicle on all vehicles.
3830 def GetNumOfSingletonNodes(self) -> "int": 3831 r""" Returns the number of non-start/end nodes which do not appear in a pickup/delivery pair.""" 3832 return _pywrapcp.RoutingModel_GetNumOfSingletonNodes(self)
Returns the number of non-start/end nodes which do not appear in a pickup/delivery pair.
When visited, one instance of type 'T' previously added to the route (TYPE_ADDED_TO_VEHICLE), if any, is removed from the vehicle. If the type was not previously added to the route or all added instances have already been removed, this visit has no effect on the types.
With the following policy, the visit enforces that type 'T' is considered on the route from its start until this node is visited.
The visit doesn't have an impact on the number of types 'T' on the route, as it's (virtually) added and removed directly. This policy can be used for visits which are part of an incompatibility or requirement set without affecting the type count on the route.
3857 def CloseVisitTypes(self) -> "void": 3858 r""" This function should be called once all node visit types have been set and prior to adding any incompatibilities/requirements. "close" types.""" 3859 return _pywrapcp.RoutingModel_CloseVisitTypes(self)
This function should be called once all node visit types have been set and prior to adding any incompatibilities/requirements. "close" types.
3864 def AddHardTypeIncompatibility(self, type1: "int", type2: "int") -> "void": 3865 r""" Incompatibilities: Two nodes with "hard" incompatible types cannot share the same route at all, while with a "temporal" incompatibility they can't be on the same route at the same time.""" 3866 return _pywrapcp.RoutingModel_AddHardTypeIncompatibility(self, type1, type2)
Incompatibilities: Two nodes with "hard" incompatible types cannot share the same route at all, while with a "temporal" incompatibility they can't be on the same route at the same time.
3871 def GetHardTypeIncompatibilitiesOfType(self, type: "int") -> "absl::flat_hash_set< int > const &": 3872 r""" Returns visit types incompatible with a given type.""" 3873 return _pywrapcp.RoutingModel_GetHardTypeIncompatibilitiesOfType(self, type)
Returns visit types incompatible with a given type.
3878 def HasHardTypeIncompatibilities(self) -> "bool": 3879 r""" Returns true iff any hard (resp. temporal) type incompatibilities have been added to the model.""" 3880 return _pywrapcp.RoutingModel_HasHardTypeIncompatibilities(self)
Returns true iff any hard (resp. temporal) type incompatibilities have been added to the model.
3885 def AddSameVehicleRequiredTypeAlternatives(self, dependent_type: "int", required_type_alternatives: "absl::flat_hash_set< int >") -> "void": 3886 r""" Requirements: NOTE: As of 2019-04, cycles in the requirement graph are not supported, and lead to the dependent nodes being skipped if possible (otherwise the model is considered infeasible). The following functions specify that "dependent_type" requires at least one of the types in "required_type_alternatives". For same-vehicle requirements, a node of dependent type type_D requires at least one node of type type_R among the required alternatives on the same route.""" 3887 return _pywrapcp.RoutingModel_AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives)
Requirements: NOTE: As of 2019-04, cycles in the requirement graph are not supported, and lead to the dependent nodes being skipped if possible (otherwise the model is considered infeasible). The following functions specify that "dependent_type" requires at least one of the types in "required_type_alternatives". For same-vehicle requirements, a node of dependent type type_D requires at least one node of type type_R among the required alternatives on the same route.
3889 def AddRequiredTypeAlternativesWhenAddingType(self, dependent_type: "int", required_type_alternatives: "absl::flat_hash_set< int >") -> "void": 3890 r""" If type_D depends on type_R when adding type_D, any node_D of type_D and VisitTypePolicy TYPE_ADDED_TO_VEHICLE or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED requires at least one type_R on its vehicle at the time node_D is visited.""" 3891 return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives)
If type_D depends on type_R when adding type_D, any node_D of type_D and VisitTypePolicy TYPE_ADDED_TO_VEHICLE or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED requires at least one type_R on its vehicle at the time node_D is visited.
3893 def AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type: "int", required_type_alternatives: "absl::flat_hash_set< int >") -> "void": 3894 r""" The following requirements apply when visiting dependent nodes that remove their type from the route, i.e. type_R must be on the vehicle when type_D of VisitTypePolicy ADDED_TYPE_REMOVED_FROM_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED is visited.""" 3895 return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives)
The following requirements apply when visiting dependent nodes that remove their type from the route, i.e. type_R must be on the vehicle when type_D of VisitTypePolicy ADDED_TYPE_REMOVED_FROM_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED is visited.
3897 def GetSameVehicleRequiredTypeAlternativesOfType(self, type: "int") -> "std::vector< absl::flat_hash_set< int > > const &": 3898 r""" Returns the set of same-vehicle requirement alternatives for the given type.""" 3899 return _pywrapcp.RoutingModel_GetSameVehicleRequiredTypeAlternativesOfType(self, type)
Returns the set of same-vehicle requirement alternatives for the given type.
3901 def GetRequiredTypeAlternativesWhenAddingType(self, type: "int") -> "std::vector< absl::flat_hash_set< int > > const &": 3902 r""" Returns the set of requirement alternatives when adding the given type.""" 3903 return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenAddingType(self, type)
Returns the set of requirement alternatives when adding the given type.
3905 def GetRequiredTypeAlternativesWhenRemovingType(self, type: "int") -> "std::vector< absl::flat_hash_set< int > > const &": 3906 r""" Returns the set of requirement alternatives when removing the given type.""" 3907 return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenRemovingType(self, type)
Returns the set of requirement alternatives when removing the given type.
3909 def HasSameVehicleTypeRequirements(self) -> "bool": 3910 r""" Returns true iff any same-route (resp. temporal) type requirements have been added to the model.""" 3911 return _pywrapcp.RoutingModel_HasSameVehicleTypeRequirements(self)
Returns true iff any same-route (resp. temporal) type requirements have been added to the model.
3916 def HasTypeRegulations(self) -> "bool": 3917 r""" Returns true iff the model has any incompatibilities or requirements set on node types.""" 3918 return _pywrapcp.RoutingModel_HasTypeRegulations(self)
Returns true iff the model has any incompatibilities or requirements set on node types.
3920 def UnperformedPenalty(self, var_index: "int64_t") -> "int64_t": 3921 r""" Get the "unperformed" penalty of a node. This is only well defined if the node is only part of a single Disjunction, and that disjunction has a penalty. For forced active nodes returns max int64_t. In all other cases, this returns 0.""" 3922 return _pywrapcp.RoutingModel_UnperformedPenalty(self, var_index)
Get the "unperformed" penalty of a node. This is only well defined if the node is only part of a single Disjunction, and that disjunction has a penalty. For forced active nodes returns max int64_t. In all other cases, this returns 0.
3924 def UnperformedPenaltyOrValue(self, default_value: "int64_t", var_index: "int64_t") -> "int64_t": 3925 r""" Same as above except that it returns default_value instead of 0 when penalty is not well defined (default value is passed as first argument to simplify the usage of the method in a callback).""" 3926 return _pywrapcp.RoutingModel_UnperformedPenaltyOrValue(self, default_value, var_index)
Same as above except that it returns default_value instead of 0 when penalty is not well defined (default value is passed as first argument to simplify the usage of the method in a callback).
3928 def GetDepot(self) -> "int64_t": 3929 r""" Returns the variable index of the first starting or ending node of all routes. If all routes start and end at the same node (single depot), this is the node returned.""" 3930 return _pywrapcp.RoutingModel_GetDepot(self)
Returns the variable index of the first starting or ending node of all routes. If all routes start and end at the same node (single depot), this is the node returned.
3932 def SetMaximumNumberOfActiveVehicles(self, max_active_vehicles: "int") -> "void": 3933 r""" Constrains the maximum number of active vehicles, aka the number of vehicles which do not have an empty route. For instance, this can be used to limit the number of routes in the case where there are fewer drivers than vehicles and that the fleet of vehicle is heterogeneous.""" 3934 return _pywrapcp.RoutingModel_SetMaximumNumberOfActiveVehicles(self, max_active_vehicles)
Constrains the maximum number of active vehicles, aka the number of vehicles which do not have an empty route. For instance, this can be used to limit the number of routes in the case where there are fewer drivers than vehicles and that the fleet of vehicle is heterogeneous.
3936 def GetMaximumNumberOfActiveVehicles(self) -> "int": 3937 r""" Returns the maximum number of active vehicles.""" 3938 return _pywrapcp.RoutingModel_GetMaximumNumberOfActiveVehicles(self)
Returns the maximum number of active vehicles.
3940 def SetArcCostEvaluatorOfAllVehicles(self, evaluator_index: "int") -> "void": 3941 r""" Sets the cost function of the model such that the cost of a segment of a route between node 'from' and 'to' is evaluator(from, to), whatever the route or vehicle performing the route.""" 3942 return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfAllVehicles(self, evaluator_index)
Sets the cost function of the model such that the cost of a segment of a route between node 'from' and 'to' is evaluator(from, to), whatever the route or vehicle performing the route.
3944 def SetArcCostEvaluatorOfVehicle(self, evaluator_index: "int", vehicle: "int") -> "void": 3945 r""" Sets the cost function for a given vehicle route.""" 3946 return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle)
Sets the cost function for a given vehicle route.
3948 def SetFixedCostOfAllVehicles(self, cost: "int64_t") -> "void": 3949 r""" Sets the fixed cost of all vehicle routes. It is equivalent to calling SetFixedCostOfVehicle on all vehicle routes.""" 3950 return _pywrapcp.RoutingModel_SetFixedCostOfAllVehicles(self, cost)
Sets the fixed cost of all vehicle routes. It is equivalent to calling SetFixedCostOfVehicle on all vehicle routes.
3952 def SetFixedCostOfVehicle(self, cost: "int64_t", vehicle: "int") -> "void": 3953 r""" Sets the fixed cost of one vehicle route.""" 3954 return _pywrapcp.RoutingModel_SetFixedCostOfVehicle(self, cost, vehicle)
Sets the fixed cost of one vehicle route.
3956 def GetFixedCostOfVehicle(self, vehicle: "int") -> "int64_t": 3957 r""" Returns the route fixed cost taken into account if the route of the vehicle is not empty, aka there's at least one node on the route other than the first and last nodes.""" 3958 return _pywrapcp.RoutingModel_GetFixedCostOfVehicle(self, vehicle)
Returns the route fixed cost taken into account if the route of the vehicle is not empty, aka there's at least one node on the route other than the first and last nodes.
3960 def SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor: "int64_t", quadratic_cost_factor: "int64_t") -> "void": 3961 r""" The following methods set the linear and quadratic cost factors of vehicles (must be positive values). The default value of these parameters is zero for all vehicles. When set, the cost_ of the model will contain terms aiming at reducing the number of vehicles used in the model, by adding the following to the objective for every vehicle v: INDICATOR(v used in the model) * [linear_cost_factor_of_vehicle_[v] - quadratic_cost_factor_of_vehicle_[v]*(square of length of route v)] i.e. for every used vehicle, we add the linear factor as fixed cost, and subtract the square of the route length multiplied by the quadratic factor. This second term aims at making the routes as dense as possible. Sets the linear and quadratic cost factor of all vehicles.""" 3962 return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor)
The following methods set the linear and quadratic cost factors of vehicles (must be positive values). The default value of these parameters is zero for all vehicles. When set, the cost_ of the model will contain terms aiming at reducing the number of vehicles used in the model, by adding the following to the objective for every vehicle v: INDICATOR(v used in the model) * [linear_cost_factor_of_vehicle_[v] - quadratic_cost_factor_of_vehicle_[v]*(square of length of route v)] i.e. for every used vehicle, we add the linear factor as fixed cost, and subtract the square of the route length multiplied by the quadratic factor. This second term aims at making the routes as dense as possible. Sets the linear and quadratic cost factor of all vehicles.
3964 def SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor: "int64_t", quadratic_cost_factor: "int64_t", vehicle: "int") -> "void": 3965 r""" Sets the linear and quadratic cost factor of the given vehicle.""" 3966 return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle)
Sets the linear and quadratic cost factor of the given vehicle.
3980 def SetFirstSolutionEvaluator(self, evaluator: "operations_research::Solver::IndexEvaluator2") -> "void": 3981 r""" Gets/sets the evaluator used during the search. Only relevant when RoutingSearchParameters.first_solution_strategy = EVALUATOR_STRATEGY. Takes ownership of evaluator.""" 3982 return _pywrapcp.RoutingModel_SetFirstSolutionEvaluator(self, evaluator)
Gets/sets the evaluator used during the search. Only relevant when RoutingSearchParameters.first_solution_strategy = EVALUATOR_STRATEGY. Takes ownership of evaluator.
3984 def AddLocalSearchOperator(self, ls_operator: "LocalSearchOperator") -> "void": 3985 r""" Adds a local search operator to the set of operators used to solve the vehicle routing problem.""" 3986 return _pywrapcp.RoutingModel_AddLocalSearchOperator(self, ls_operator)
Adds a local search operator to the set of operators used to solve the vehicle routing problem.
3988 def AddSearchMonitor(self, monitor: "SearchMonitor") -> "void": 3989 r""" Adds a search monitor to the search used to solve the routing model.""" 3990 return _pywrapcp.RoutingModel_AddSearchMonitor(self, monitor)
Adds a search monitor to the search used to solve the routing model.
3992 def AddAtSolutionCallback(self, callback: "std::function< void () >") -> "void": 3993 r""" Adds a callback called each time a solution is found during the search. This is a shortcut to creating a monitor to call the callback on AtSolution() and adding it with AddSearchMonitor.""" 3994 return _pywrapcp.RoutingModel_AddAtSolutionCallback(self, callback)
Adds a callback called each time a solution is found during the search. This is a shortcut to creating a monitor to call the callback on AtSolution() and adding it with AddSearchMonitor.
3996 def AddVariableMinimizedByFinalizer(self, var: "IntVar") -> "void": 3997 r""" Adds a variable to minimize in the solution finalizer. The solution finalizer is called each time a solution is found during the search and allows to instantiate secondary variables (such as dimension cumul variables).""" 3998 return _pywrapcp.RoutingModel_AddVariableMinimizedByFinalizer(self, var)
Adds a variable to minimize in the solution finalizer. The solution finalizer is called each time a solution is found during the search and allows to instantiate secondary variables (such as dimension cumul variables).
4000 def AddVariableMaximizedByFinalizer(self, var: "IntVar") -> "void": 4001 r""" Adds a variable to maximize in the solution finalizer (see above for information on the solution finalizer).""" 4002 return _pywrapcp.RoutingModel_AddVariableMaximizedByFinalizer(self, var)
Adds a variable to maximize in the solution finalizer (see above for information on the solution finalizer).
4004 def AddWeightedVariableMinimizedByFinalizer(self, var: "IntVar", cost: "int64_t") -> "void": 4005 r""" Adds a variable to minimize in the solution finalizer, with a weighted priority: the higher the more priority it has.""" 4006 return _pywrapcp.RoutingModel_AddWeightedVariableMinimizedByFinalizer(self, var, cost)
Adds a variable to minimize in the solution finalizer, with a weighted priority: the higher the more priority it has.
4008 def AddWeightedVariableMaximizedByFinalizer(self, var: "IntVar", cost: "int64_t") -> "void": 4009 r""" Adds a variable to maximize in the solution finalizer, with a weighted priority: the higher the more priority it has.""" 4010 return _pywrapcp.RoutingModel_AddWeightedVariableMaximizedByFinalizer(self, var, cost)
Adds a variable to maximize in the solution finalizer, with a weighted priority: the higher the more priority it has.
4012 def AddVariableTargetToFinalizer(self, var: "IntVar", target: "int64_t") -> "void": 4013 r""" Add a variable to set the closest possible to the target value in the solution finalizer.""" 4014 return _pywrapcp.RoutingModel_AddVariableTargetToFinalizer(self, var, target)
Add a variable to set the closest possible to the target value in the solution finalizer.
4016 def AddWeightedVariableTargetToFinalizer(self, var: "IntVar", target: "int64_t", cost: "int64_t") -> "void": 4017 r""" Same as above with a weighted priority: the higher the cost, the more priority it has to be set close to the target value.""" 4018 return _pywrapcp.RoutingModel_AddWeightedVariableTargetToFinalizer(self, var, target, cost)
Same as above with a weighted priority: the higher the cost, the more priority it has to be set close to the target value.
4020 def CloseModel(self) -> "void": 4021 r""" Closes the current routing model; after this method is called, no modification to the model can be done, but RoutesToAssignment becomes available. Note that CloseModel() is automatically called by Solve() and other methods that produce solution. This is equivalent to calling CloseModelWithParameters(DefaultRoutingSearchParameters()).""" 4022 return _pywrapcp.RoutingModel_CloseModel(self)
Closes the current routing model; after this method is called, no modification to the model can be done, but RoutesToAssignment becomes available. Note that CloseModel() is automatically called by Solve() and other methods that produce solution. This is equivalent to calling CloseModelWithParameters(DefaultRoutingSearchParameters()).
4024 def CloseModelWithParameters(self, search_parameters: "operations_research::RoutingSearchParameters const &") -> "void": 4025 r""" Same as above taking search parameters (as of 10/2015 some the parameters have to be set when closing the model).""" 4026 return _pywrapcp.RoutingModel_CloseModelWithParameters(self, search_parameters)
Same as above taking search parameters (as of 10/2015 some the parameters have to be set when closing the model).
4028 def Solve(self, assignment: "Assignment"=None) -> "operations_research::Assignment const *": 4029 r""" Solves the current routing model; closes the current model. This is equivalent to calling SolveWithParameters(DefaultRoutingSearchParameters()) or SolveFromAssignmentWithParameters(assignment, DefaultRoutingSearchParameters()).""" 4030 return _pywrapcp.RoutingModel_Solve(self, assignment)
Solves the current routing model; closes the current model. This is equivalent to calling SolveWithParameters(DefaultRoutingSearchParameters()) or SolveFromAssignmentWithParameters(assignment, DefaultRoutingSearchParameters()).
4032 def SolveWithParameters(self, search_parameters: "operations_research::RoutingSearchParameters const &", solutions: "std::vector< operations_research::Assignment const * > *"=None) -> "operations_research::Assignment const *": 4033 r""" Solves the current routing model with the given parameters. If 'solutions' is specified, it will contain the k best solutions found during the search (from worst to best, including the one returned by this method), where k corresponds to the 'number_of_solutions_to_collect' in 'search_parameters'. Note that the Assignment returned by the method and the ones in solutions are owned by the underlying solver and should not be deleted.""" 4034 return _pywrapcp.RoutingModel_SolveWithParameters(self, search_parameters, solutions)
Solves the current routing model with the given parameters. If 'solutions' is specified, it will contain the k best solutions found during the search (from worst to best, including the one returned by this method), where k corresponds to the 'number_of_solutions_to_collect' in 'search_parameters'. Note that the Assignment returned by the method and the ones in solutions are owned by the underlying solver and should not be deleted.
4036 def SolveFromAssignmentWithParameters(self, assignment: "Assignment", search_parameters: "operations_research::RoutingSearchParameters const &", solutions: "std::vector< operations_research::Assignment const * > *"=None) -> "operations_research::Assignment const *": 4037 r""" Same as above, except that if assignment is not null, it will be used as the initial solution.""" 4038 return _pywrapcp.RoutingModel_SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions)
Same as above, except that if assignment is not null, it will be used as the initial solution.
4040 def SolveFromAssignmentsWithParameters(self, assignments: "std::vector< operations_research::Assignment const * > const &", search_parameters: "operations_research::RoutingSearchParameters const &", solutions: "std::vector< operations_research::Assignment const * > *"=None) -> "operations_research::Assignment const *": 4041 r""" Same as above but will try all assignments in order as first solutions until one succeeds.""" 4042 return _pywrapcp.RoutingModel_SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions)
Same as above but will try all assignments in order as first solutions until one succeeds.
4044 def SetAssignmentFromOtherModelAssignment(self, target_assignment: "Assignment", source_model: "RoutingModel", source_assignment: "Assignment") -> "void": 4045 r""" Given a "source_model" and its "source_assignment", resets "target_assignment" with the IntVar variables (nexts_, and vehicle_vars_ if costs aren't homogeneous across vehicles) of "this" model, with the values set according to those in "other_assignment". The objective_element of target_assignment is set to this->cost_.""" 4046 return _pywrapcp.RoutingModel_SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment)
Given a "source_model" and its "source_assignment", resets "target_assignment" with the IntVar variables (nexts_, and vehicle_vars_ if costs aren't homogeneous across vehicles) of "this" model, with the values set according to those in "other_assignment". The objective_element of target_assignment is set to this->cost_.
4048 def ComputeLowerBound(self) -> "int64_t": 4049 r""" Computes a lower bound to the routing problem solving a linear assignment problem. The routing model must be closed before calling this method. Note that problems with node disjunction constraints (including optional nodes) and non-homogenous costs are not supported (the method returns 0 in these cases).""" 4050 return _pywrapcp.RoutingModel_ComputeLowerBound(self)
Computes a lower bound to the routing problem solving a linear assignment problem. The routing model must be closed before calling this method. Note that problems with node disjunction constraints (including optional nodes) and non-homogenous costs are not supported (the method returns 0 in these cases).
4052 def status(self) -> "operations_research::RoutingModel::Status": 4053 r""" Returns the current status of the routing model.""" 4054 return _pywrapcp.RoutingModel_status(self)
Returns the current status of the routing model.
4056 def enable_deep_serialization(self) -> "bool": 4057 r""" Returns the value of the internal enable_deep_serialization_ parameter.""" 4058 return _pywrapcp.RoutingModel_enable_deep_serialization(self)
Returns the value of the internal enable_deep_serialization_ parameter.
4060 def ApplyLocks(self, locks: "std::vector< int64_t > const &") -> "operations_research::IntVar *": 4061 r""" Applies a lock chain to the next search. 'locks' represents an ordered vector of nodes representing a partial route which will be fixed during the next search; it will constrain next variables such that: next[locks[i]] == locks[i+1]. Returns the next variable at the end of the locked chain; this variable is not locked. An assignment containing the locks can be obtained by calling PreAssignment().""" 4062 return _pywrapcp.RoutingModel_ApplyLocks(self, locks)
Applies a lock chain to the next search. 'locks' represents an ordered vector of nodes representing a partial route which will be fixed during the next search; it will constrain next variables such that: next[locks[i]] == locks[i+1]. Returns the next variable at the end of the locked chain; this variable is not locked. An assignment containing the locks can be obtained by calling PreAssignment().
4064 def ApplyLocksToAllVehicles(self, locks: "std::vector< std::vector< int64_t > > const &", close_routes: "bool") -> "bool": 4065 r""" Applies lock chains to all vehicles to the next search, such that locks[p] is the lock chain for route p. Returns false if the locks do not contain valid routes; expects that the routes do not contain the depots, i.e. there are empty vectors in place of empty routes. If close_routes is set to true, adds the end nodes to the route of each vehicle and deactivates other nodes. An assignment containing the locks can be obtained by calling PreAssignment().""" 4066 return _pywrapcp.RoutingModel_ApplyLocksToAllVehicles(self, locks, close_routes)
Applies lock chains to all vehicles to the next search, such that locks[p] is the lock chain for route p. Returns false if the locks do not contain valid routes; expects that the routes do not contain the depots, i.e. there are empty vectors in place of empty routes. If close_routes is set to true, adds the end nodes to the route of each vehicle and deactivates other nodes. An assignment containing the locks can be obtained by calling PreAssignment().
4068 def PreAssignment(self) -> "operations_research::Assignment const *const": 4069 r""" Returns an assignment used to fix some of the variables of the problem. In practice, this assignment locks partial routes of the problem. This can be used in the context of locking the parts of the routes which have already been driven in online routing problems.""" 4070 return _pywrapcp.RoutingModel_PreAssignment(self)
Returns an assignment used to fix some of the variables of the problem. In practice, this assignment locks partial routes of the problem. This can be used in the context of locking the parts of the routes which have already been driven in online routing problems.
4075 def WriteAssignment(self, file_name: "std::string const &") -> "bool": 4076 r""" Writes the current solution to a file containing an AssignmentProto. Returns false if the file cannot be opened or if there is no current solution.""" 4077 return _pywrapcp.RoutingModel_WriteAssignment(self, file_name)
Writes the current solution to a file containing an AssignmentProto. Returns false if the file cannot be opened or if there is no current solution.
4079 def ReadAssignment(self, file_name: "std::string const &") -> "operations_research::Assignment *": 4080 r""" Reads an assignment from a file and returns the current solution. Returns nullptr if the file cannot be opened or if the assignment is not valid.""" 4081 return _pywrapcp.RoutingModel_ReadAssignment(self, file_name)
Reads an assignment from a file and returns the current solution. Returns nullptr if the file cannot be opened or if the assignment is not valid.
4083 def RestoreAssignment(self, solution: "Assignment") -> "operations_research::Assignment *": 4084 r""" Restores an assignment as a solution in the routing model and returns the new solution. Returns nullptr if the assignment is not valid.""" 4085 return _pywrapcp.RoutingModel_RestoreAssignment(self, solution)
Restores an assignment as a solution in the routing model and returns the new solution. Returns nullptr if the assignment is not valid.
4087 def ReadAssignmentFromRoutes(self, routes: "std::vector< std::vector< int64_t > > const &", ignore_inactive_indices: "bool") -> "operations_research::Assignment *": 4088 r""" Restores the routes as the current solution. Returns nullptr if the solution cannot be restored (routes do not contain a valid solution). Note that calling this method will run the solver to assign values to the dimension variables; this may take considerable amount of time, especially when using dimensions with slack.""" 4089 return _pywrapcp.RoutingModel_ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices)
Restores the routes as the current solution. Returns nullptr if the solution cannot be restored (routes do not contain a valid solution). Note that calling this method will run the solver to assign values to the dimension variables; this may take considerable amount of time, especially when using dimensions with slack.
4091 def RoutesToAssignment(self, routes: "std::vector< std::vector< int64_t > > const &", ignore_inactive_indices: "bool", close_routes: "bool", assignment: "Assignment") -> "bool": 4092 r""" Fills an assignment from a specification of the routes of the vehicles. The routes are specified as lists of variable indices that appear on the routes of the vehicles. The indices of the outer vector in 'routes' correspond to vehicles IDs, the inner vector contains the variable indices on the routes for the given vehicle. The inner vectors must not contain the start and end indices, as these are determined by the routing model. Sets the value of NextVars in the assignment, adding the variables to the assignment if necessary. The method does not touch other variables in the assignment. The method can only be called after the model is closed. With ignore_inactive_indices set to false, this method will fail (return nullptr) in case some of the route contain indices that are deactivated in the model; when set to true, these indices will be skipped. Returns true if routes were successfully loaded. However, such assignment still might not be a valid solution to the routing problem due to more complex constraints; it is advisible to call solver()->CheckSolution() afterwards.""" 4093 return _pywrapcp.RoutingModel_RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment)
Fills an assignment from a specification of the routes of the vehicles. The routes are specified as lists of variable indices that appear on the routes of the vehicles. The indices of the outer vector in 'routes' correspond to vehicles IDs, the inner vector contains the variable indices on the routes for the given vehicle. The inner vectors must not contain the start and end indices, as these are determined by the routing model. Sets the value of NextVars in the assignment, adding the variables to the assignment if necessary. The method does not touch other variables in the assignment. The method can only be called after the model is closed. With ignore_inactive_indices set to false, this method will fail (return nullptr) in case some of the route contain indices that are deactivated in the model; when set to true, these indices will be skipped. Returns true if routes were successfully loaded. However, such assignment still might not be a valid solution to the routing problem due to more complex constraints; it is advisible to call solver()->CheckSolution() afterwards.
4095 def AssignmentToRoutes(self, assignment: "Assignment", routes: "std::vector< std::vector< int64_t > > *const") -> "void": 4096 r""" Converts the solution in the given assignment to routes for all vehicles. Expects that assignment contains a valid solution (i.e. routes for all vehicles end with an end index for that vehicle).""" 4097 return _pywrapcp.RoutingModel_AssignmentToRoutes(self, assignment, routes)
Converts the solution in the given assignment to routes for all vehicles. Expects that assignment contains a valid solution (i.e. routes for all vehicles end with an end index for that vehicle).
4099 def CompactAssignment(self, assignment: "Assignment") -> "operations_research::Assignment *": 4100 r""" Converts the solution in the given assignment to routes for all vehicles. If the returned vector is route_indices, route_indices[i][j] is the index for jth location visited on route i. Note that contrary to AssignmentToRoutes, the vectors do include start and end locations. Returns a compacted version of the given assignment, in which all vehicles with id lower or equal to some N have non-empty routes, and all vehicles with id greater than N have empty routes. Does not take ownership of the returned object. If found, the cost of the compact assignment is the same as in the original assignment and it preserves the values of 'active' variables. Returns nullptr if a compact assignment was not found. This method only works in homogenous mode, and it only swaps equivalent vehicles (vehicles with the same start and end nodes). When creating the compact assignment, the empty plan is replaced by the route assigned to the compatible vehicle with the highest id. Note that with more complex constraints on vehicle variables, this method might fail even if a compact solution exists. This method changes the vehicle and dimension variables as necessary. While compacting the solution, only basic checks on vehicle variables are performed; if one of these checks fails no attempts to repair it are made (instead, the method returns nullptr).""" 4101 return _pywrapcp.RoutingModel_CompactAssignment(self, assignment)
Converts the solution in the given assignment to routes for all vehicles. If the returned vector is route_indices, route_indices[i][j] is the index for jth location visited on route i. Note that contrary to AssignmentToRoutes, the vectors do include start and end locations. Returns a compacted version of the given assignment, in which all vehicles with id lower or equal to some N have non-empty routes, and all vehicles with id greater than N have empty routes. Does not take ownership of the returned object. If found, the cost of the compact assignment is the same as in the original assignment and it preserves the values of 'active' variables. Returns nullptr if a compact assignment was not found. This method only works in homogenous mode, and it only swaps equivalent vehicles (vehicles with the same start and end nodes). When creating the compact assignment, the empty plan is replaced by the route assigned to the compatible vehicle with the highest id. Note that with more complex constraints on vehicle variables, this method might fail even if a compact solution exists. This method changes the vehicle and dimension variables as necessary. While compacting the solution, only basic checks on vehicle variables are performed; if one of these checks fails no attempts to repair it are made (instead, the method returns nullptr).
4103 def CompactAndCheckAssignment(self, assignment: "Assignment") -> "operations_research::Assignment *": 4104 r""" Same as CompactAssignment() but also checks the validity of the final compact solution; if it is not valid, no attempts to repair it are made (instead, the method returns nullptr).""" 4105 return _pywrapcp.RoutingModel_CompactAndCheckAssignment(self, assignment)
Same as CompactAssignment() but also checks the validity of the final compact solution; if it is not valid, no attempts to repair it are made (instead, the method returns nullptr).
4107 def AddToAssignment(self, var: "IntVar") -> "void": 4108 r""" Adds an extra variable to the vehicle routing assignment.""" 4109 return _pywrapcp.RoutingModel_AddToAssignment(self, var)
Adds an extra variable to the vehicle routing assignment.
4114 def PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment: "Assignment", duration_limit: "absl::Duration", time_limit_was_reached: "bool *"=None) -> "operations_research::Assignment const *": 4115 r""" For every dimension in the model with an optimizer in local/global_dimension_optimizers_, this method tries to pack the cumul values of the dimension, such that: - The cumul costs (span costs, soft lower and upper bound costs, etc) are minimized. - The cumuls of the ends of the routes are minimized for this given minimal cumul cost. - Given these minimal end cumuls, the route start cumuls are maximized. Returns the assignment resulting from allocating these packed cumuls with the solver, and nullptr if these cumuls could not be set by the solver.""" 4116 return _pywrapcp.RoutingModel_PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached)
For every dimension in the model with an optimizer in local/global_dimension_optimizers_, this method tries to pack the cumul values of the dimension, such that: - The cumul costs (span costs, soft lower and upper bound costs, etc) are minimized. - The cumuls of the ends of the routes are minimized for this given minimal cumul cost. - Given these minimal end cumuls, the route start cumuls are maximized. Returns the assignment resulting from allocating these packed cumuls with the solver, and nullptr if these cumuls could not be set by the solver.
4118 def AddLocalSearchFilter(self, filter: "LocalSearchFilter") -> "void": 4119 r""" Adds a custom local search filter to the list of filters used to speed up local search by pruning unfeasible variable assignments. Calling this method after the routing model has been closed (CloseModel() or Solve() has been called) has no effect. The routing model does not take ownership of the filter.""" 4120 return _pywrapcp.RoutingModel_AddLocalSearchFilter(self, filter)
Adds a custom local search filter to the list of filters used to speed up local search by pruning unfeasible variable assignments. Calling this method after the routing model has been closed (CloseModel() or Solve() has been called) has no effect. The routing model does not take ownership of the filter.
4122 def Start(self, vehicle: "int") -> "int64_t": 4123 r""" Model inspection. Returns the variable index of the starting node of a vehicle route.""" 4124 return _pywrapcp.RoutingModel_Start(self, vehicle)
Model inspection. Returns the variable index of the starting node of a vehicle route.
4126 def End(self, vehicle: "int") -> "int64_t": 4127 r""" Returns the variable index of the ending node of a vehicle route.""" 4128 return _pywrapcp.RoutingModel_End(self, vehicle)
Returns the variable index of the ending node of a vehicle route.
4130 def IsStart(self, index: "int64_t") -> "bool": 4131 r""" Returns true if 'index' represents the first node of a route.""" 4132 return _pywrapcp.RoutingModel_IsStart(self, index)
Returns true if 'index' represents the first node of a route.
4134 def IsEnd(self, index: "int64_t") -> "bool": 4135 r""" Returns true if 'index' represents the last node of a route.""" 4136 return _pywrapcp.RoutingModel_IsEnd(self, index)
Returns true if 'index' represents the last node of a route.
4138 def VehicleIndex(self, index: "int64_t") -> "int": 4139 r""" Returns the vehicle of the given start/end index, and -1 if the given index is not a vehicle start/end.""" 4140 return _pywrapcp.RoutingModel_VehicleIndex(self, index)
Returns the vehicle of the given start/end index, and -1 if the given index is not a vehicle start/end.
4142 def Next(self, assignment: "Assignment", index: "int64_t") -> "int64_t": 4143 r""" Assignment inspection Returns the variable index of the node directly after the node corresponding to 'index' in 'assignment'.""" 4144 return _pywrapcp.RoutingModel_Next(self, assignment, index)
Assignment inspection Returns the variable index of the node directly after the node corresponding to 'index' in 'assignment'.
4146 def IsVehicleUsed(self, assignment: "Assignment", vehicle: "int") -> "bool": 4147 r""" Returns true if the route of 'vehicle' is non empty in 'assignment'.""" 4148 return _pywrapcp.RoutingModel_IsVehicleUsed(self, assignment, vehicle)
Returns true if the route of 'vehicle' is non empty in 'assignment'.
4150 def NextVar(self, index: "int64_t") -> "operations_research::IntVar *": 4151 r""" Returns the next variable of the node corresponding to index. Note that NextVar(index) == index is equivalent to ActiveVar(index) == 0.""" 4152 return _pywrapcp.RoutingModel_NextVar(self, index)
Returns the next variable of the node corresponding to index. Note that NextVar(index) == index is equivalent to ActiveVar(index) == 0.
4154 def ActiveVar(self, index: "int64_t") -> "operations_research::IntVar *": 4155 r""" Returns the active variable of the node corresponding to index.""" 4156 return _pywrapcp.RoutingModel_ActiveVar(self, index)
Returns the active variable of the node corresponding to index.
4158 def ActiveVehicleVar(self, vehicle: "int") -> "operations_research::IntVar *": 4159 r""" Returns the active variable of the vehicle. It will be equal to 1 iff the route of the vehicle is not empty, 0 otherwise.""" 4160 return _pywrapcp.RoutingModel_ActiveVehicleVar(self, vehicle)
Returns the active variable of the vehicle. It will be equal to 1 iff the route of the vehicle is not empty, 0 otherwise.
4162 def VehicleRouteConsideredVar(self, vehicle: "int") -> "operations_research::IntVar *": 4163 r""" Returns the variable specifying whether or not the given vehicle route is considered for costs and constraints. It will be equal to 1 iff the route of the vehicle is not empty OR vehicle_used_when_empty_[vehicle] is true.""" 4164 return _pywrapcp.RoutingModel_VehicleRouteConsideredVar(self, vehicle)
Returns the variable specifying whether or not the given vehicle route is considered for costs and constraints. It will be equal to 1 iff the route of the vehicle is not empty OR vehicle_used_when_empty_[vehicle] is true.
4166 def VehicleVar(self, index: "int64_t") -> "operations_research::IntVar *": 4167 r""" Returns the vehicle variable of the node corresponding to index. Note that VehicleVar(index) == -1 is equivalent to ActiveVar(index) == 0.""" 4168 return _pywrapcp.RoutingModel_VehicleVar(self, index)
Returns the vehicle variable of the node corresponding to index. Note that VehicleVar(index) == -1 is equivalent to ActiveVar(index) == 0.
4170 def ResourceVar(self, vehicle: "int", resource_group: "int") -> "operations_research::IntVar *": 4171 r""" Returns the resource variable for the given vehicle index in the given resource group. If a vehicle doesn't require a resource from the corresponding resource group, then ResourceVar(v, r_g) == -1.""" 4172 return _pywrapcp.RoutingModel_ResourceVar(self, vehicle, resource_group)
Returns the resource variable for the given vehicle index in the given resource group. If a vehicle doesn't require a resource from the corresponding resource group, then ResourceVar(v, r_g) == -1.
4174 def CostVar(self) -> "operations_research::IntVar *": 4175 r""" Returns the global cost variable which is being minimized.""" 4176 return _pywrapcp.RoutingModel_CostVar(self)
Returns the global cost variable which is being minimized.
4178 def GetArcCostForVehicle(self, from_index: "int64_t", to_index: "int64_t", vehicle: "int64_t") -> "int64_t": 4179 r""" Returns the cost of the transit arc between two nodes for a given vehicle. Input are variable indices of node. This returns 0 if vehicle < 0.""" 4180 return _pywrapcp.RoutingModel_GetArcCostForVehicle(self, from_index, to_index, vehicle)
Returns the cost of the transit arc between two nodes for a given vehicle. Input are variable indices of node. This returns 0 if vehicle < 0.
4182 def CostsAreHomogeneousAcrossVehicles(self) -> "bool": 4183 r""" Whether costs are homogeneous across all vehicles.""" 4184 return _pywrapcp.RoutingModel_CostsAreHomogeneousAcrossVehicles(self)
Whether costs are homogeneous across all vehicles.
4186 def GetHomogeneousCost(self, from_index: "int64_t", to_index: "int64_t") -> "int64_t": 4187 r""" Returns the cost of the segment between two nodes supposing all vehicle costs are the same (returns the cost for the first vehicle otherwise).""" 4188 return _pywrapcp.RoutingModel_GetHomogeneousCost(self, from_index, to_index)
Returns the cost of the segment between two nodes supposing all vehicle costs are the same (returns the cost for the first vehicle otherwise).
4190 def GetArcCostForFirstSolution(self, from_index: "int64_t", to_index: "int64_t") -> "int64_t": 4191 r""" Returns the cost of the arc in the context of the first solution strategy. This is typically a simplification of the actual cost; see the .cc.""" 4192 return _pywrapcp.RoutingModel_GetArcCostForFirstSolution(self, from_index, to_index)
Returns the cost of the arc in the context of the first solution strategy. This is typically a simplification of the actual cost; see the .cc.
4194 def GetArcCostForClass(self, from_index: "int64_t", to_index: "int64_t", cost_class_index: "int64_t") -> "int64_t": 4195 r""" Returns the cost of the segment between two nodes for a given cost class. Input are variable indices of nodes and the cost class. Unlike GetArcCostForVehicle(), if cost_class is kNoCost, then the returned cost won't necessarily be zero: only some of the components of the cost that depend on the cost class will be omited. See the code for details.""" 4196 return _pywrapcp.RoutingModel_GetArcCostForClass(self, from_index, to_index, cost_class_index)
Returns the cost of the segment between two nodes for a given cost class. Input are variable indices of nodes and the cost class. Unlike GetArcCostForVehicle(), if cost_class is kNoCost, then the returned cost won't necessarily be zero: only some of the components of the cost that depend on the cost class will be omited. See the code for details.
4198 def GetCostClassIndexOfVehicle(self, vehicle: "int64_t") -> "operations_research::RoutingModel::CostClassIndex": 4199 r""" Get the cost class index of the given vehicle.""" 4200 return _pywrapcp.RoutingModel_GetCostClassIndexOfVehicle(self, vehicle)
Get the cost class index of the given vehicle.
4202 def HasVehicleWithCostClassIndex(self, cost_class_index: "operations_research::RoutingModel::CostClassIndex") -> "bool": 4203 r""" Returns true iff the model contains a vehicle with the given cost_class_index.""" 4204 return _pywrapcp.RoutingModel_HasVehicleWithCostClassIndex(self, cost_class_index)
Returns true iff the model contains a vehicle with the given cost_class_index.
4206 def GetCostClassesCount(self) -> "int": 4207 r""" Returns the number of different cost classes in the model.""" 4208 return _pywrapcp.RoutingModel_GetCostClassesCount(self)
Returns the number of different cost classes in the model.
4210 def GetNonZeroCostClassesCount(self) -> "int": 4211 r""" Ditto, minus the 'always zero', built-in cost class.""" 4212 return _pywrapcp.RoutingModel_GetNonZeroCostClassesCount(self)
Ditto, minus the 'always zero', built-in cost class.
4217 def GetVehicleOfClass(self, vehicle_class: "operations_research::RoutingModel::VehicleClassIndex") -> "int": 4218 r""" Returns a vehicle of the given vehicle class, and -1 if there are no vehicles for this class.""" 4219 return _pywrapcp.RoutingModel_GetVehicleOfClass(self, vehicle_class)
Returns a vehicle of the given vehicle class, and -1 if there are no vehicles for this class.
4221 def GetVehicleClassesCount(self) -> "int": 4222 r""" Returns the number of different vehicle classes in the model.""" 4223 return _pywrapcp.RoutingModel_GetVehicleClassesCount(self)
Returns the number of different vehicle classes in the model.
4225 def GetSameVehicleIndicesOfIndex(self, node: "int") -> "std::vector< int > const &": 4226 r""" Returns variable indices of nodes constrained to be on the same route.""" 4227 return _pywrapcp.RoutingModel_GetSameVehicleIndicesOfIndex(self, node)
Returns variable indices of nodes constrained to be on the same route.
4232 def ArcIsMoreConstrainedThanArc(self, _from: "int64_t", to1: "int64_t", to2: "int64_t") -> "bool": 4233 r""" Returns whether the arc from->to1 is more constrained than from->to2, taking into account, in order: - whether the destination node isn't an end node - whether the destination node is mandatory - whether the destination node is bound to the same vehicle as the source - the "primary constrained" dimension (see SetPrimaryConstrainedDimension) It then breaks ties using, in order: - the arc cost (taking unperformed penalties into account) - the size of the vehicle vars of "to1" and "to2" (lowest size wins) - the value: the lowest value of the indices to1 and to2 wins. See the .cc for details. The more constrained arc is typically preferable when building a first solution. This method is intended to be used as a callback for the BestValueByComparisonSelector value selector. Args: from: the variable index of the source node to1: the variable index of the first candidate destination node. to2: the variable index of the second candidate destination node.""" 4234 return _pywrapcp.RoutingModel_ArcIsMoreConstrainedThanArc(self, _from, to1, to2)
Returns whether the arc from->to1 is more constrained than from->to2, taking into account, in order: - whether the destination node isn't an end node - whether the destination node is mandatory - whether the destination node is bound to the same vehicle as the source - the "primary constrained" dimension (see SetPrimaryConstrainedDimension) It then breaks ties using, in order: - the arc cost (taking unperformed penalties into account) - the size of the vehicle vars of "to1" and "to2" (lowest size wins) - the value: the lowest value of the indices to1 and to2 wins. See the .cc for details. The more constrained arc is typically preferable when building a first solution. This method is intended to be used as a callback for the BestValueByComparisonSelector value selector. Args: from: the variable index of the source node to1: the variable index of the first candidate destination node. to2: the variable index of the second candidate destination node.
4236 def DebugOutputAssignment(self, solution_assignment: "Assignment", dimension_to_print: "std::string const &") -> "std::string": 4237 r""" Print some debugging information about an assignment, including the feasible intervals of the CumulVar for dimension "dimension_to_print" at each step of the routes. If "dimension_to_print" is omitted, all dimensions will be printed.""" 4238 return _pywrapcp.RoutingModel_DebugOutputAssignment(self, solution_assignment, dimension_to_print)
Print some debugging information about an assignment, including the feasible intervals of the CumulVar for dimension "dimension_to_print" at each step of the routes. If "dimension_to_print" is omitted, all dimensions will be printed.
4240 def solver(self) -> "operations_research::Solver *": 4241 r""" Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair containing the minimum and maximum of the CumulVar of the jth node on route i. - cumul_bounds[i][j].first is the minimum. - cumul_bounds[i][j].second is the maximum. Returns the underlying constraint solver. Can be used to add extra constraints and/or modify search algorithms.""" 4242 return _pywrapcp.RoutingModel_solver(self)
Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair containing the minimum and maximum of the CumulVar of the jth node on route i. - cumul_bounds[i][j].first is the minimum. - cumul_bounds[i][j].second is the maximum. Returns the underlying constraint solver. Can be used to add extra constraints and/or modify search algorithms.
4244 def CheckLimit(self) -> "bool": 4245 r""" Returns true if the search limit has been crossed.""" 4246 return _pywrapcp.RoutingModel_CheckLimit(self)
Returns true if the search limit has been crossed.
4248 def RemainingTime(self) -> "absl::Duration": 4249 r""" Returns the time left in the search limit.""" 4250 return _pywrapcp.RoutingModel_RemainingTime(self)
Returns the time left in the search limit.
4252 def nodes(self) -> "int": 4253 r""" Sizes and indices Returns the number of nodes in the model.""" 4254 return _pywrapcp.RoutingModel_nodes(self)
Sizes and indices Returns the number of nodes in the model.
4256 def vehicles(self) -> "int": 4257 r""" Returns the number of vehicle routes in the model.""" 4258 return _pywrapcp.RoutingModel_vehicles(self)
Returns the number of vehicle routes in the model.
4260 def Size(self) -> "int64_t": 4261 r""" Returns the number of next variables in the model.""" 4262 return _pywrapcp.RoutingModel_Size(self)
Returns the number of next variables in the model.
4264 def GetNumberOfDecisionsInFirstSolution(self, search_parameters: "operations_research::RoutingSearchParameters const &") -> "int64_t": 4265 r""" Returns statistics on first solution search, number of decisions sent to filters, number of decisions rejected by filters.""" 4266 return _pywrapcp.RoutingModel_GetNumberOfDecisionsInFirstSolution(self, search_parameters)
Returns statistics on first solution search, number of decisions sent to filters, number of decisions rejected by filters.
4271 def GetAutomaticFirstSolutionStrategy(self) -> "operations_research::FirstSolutionStrategy::Value": 4272 r""" Returns the automatic first solution strategy selected.""" 4273 return _pywrapcp.RoutingModel_GetAutomaticFirstSolutionStrategy(self)
Returns the automatic first solution strategy selected.
4275 def IsMatchingModel(self) -> "bool": 4276 r""" Returns true if a vehicle/node matching problem is detected.""" 4277 return _pywrapcp.RoutingModel_IsMatchingModel(self)
Returns true if a vehicle/node matching problem is detected.
4279 def AreRoutesInterdependent(self, parameters: "operations_research::RoutingSearchParameters const &") -> "bool": 4280 r""" Returns true if routes are interdependent. This means that any modification to a route might impact another.""" 4281 return _pywrapcp.RoutingModel_AreRoutesInterdependent(self, parameters)
Returns true if routes are interdependent. This means that any modification to a route might impact another.
4283 def MakeGuidedSlackFinalizer(self, dimension: "RoutingDimension", initializer: "std::function< int64_t (int64_t) >") -> "operations_research::DecisionBuilder *": 4284 r""" The next few members are in the public section only for testing purposes. MakeGuidedSlackFinalizer creates a DecisionBuilder for the slacks of a dimension using a callback to choose which values to start with. The finalizer works only when all next variables in the model have been fixed. It has the following two characteristics: 1. It follows the routes defined by the nexts variables when choosing a variable to make a decision on. 2. When it comes to choose a value for the slack of node i, the decision builder first calls the callback with argument i, and supposingly the returned value is x it creates decisions slack[i] = x, slack[i] = x + 1, slack[i] = x - 1, slack[i] = x + 2, etc.""" 4285 return _pywrapcp.RoutingModel_MakeGuidedSlackFinalizer(self, dimension, initializer)
The next few members are in the public section only for testing purposes. MakeGuidedSlackFinalizer creates a DecisionBuilder for the slacks of a dimension using a callback to choose which values to start with. The finalizer works only when all next variables in the model have been fixed. It has the following two characteristics: 1. It follows the routes defined by the nexts variables when choosing a variable to make a decision on. 2. When it comes to choose a value for the slack of node i, the decision builder first calls the callback with argument i, and supposingly the returned value is x it creates decisions slack[i] = x, slack[i] = x + 1, slack[i] = x - 1, slack[i] = x + 2, etc.
4287 def MakeSelfDependentDimensionFinalizer(self, dimension: "RoutingDimension") -> "operations_research::DecisionBuilder *": 4288 r""" MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a self-dependent dimension. It makes an extensive use of the caches of the state dependent transits. In detail, MakeSelfDependentDimensionFinalizer returns a composition of a local search decision builder with a greedy descent operator for the cumul of the start of each route and a guided slack finalizer. Provided there are no time windows and the maximum slacks are large enough, once the cumul of the start of route is fixed, the guided finalizer can find optimal values of the slacks for the rest of the route in time proportional to the length of the route. Therefore the composed finalizer generally works in time O(log(t)*n*m), where t is the latest possible departute time, n is the number of nodes in the network and m is the number of vehicles.""" 4289 return _pywrapcp.RoutingModel_MakeSelfDependentDimensionFinalizer(self, dimension)
MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a self-dependent dimension. It makes an extensive use of the caches of the state dependent transits. In detail, MakeSelfDependentDimensionFinalizer returns a composition of a local search decision builder with a greedy descent operator for the cumul of the start of each route and a guided slack finalizer. Provided there are no time windows and the maximum slacks are large enough, once the cumul of the start of route is fixed, the guided finalizer can find optimal values of the slacks for the rest of the route in time proportional to the length of the route. Therefore the composed finalizer generally works in time O(log(t)nm), where t is the latest possible departute time, n is the number of nodes in the network and m is the number of vehicles.
4298class RoutingModelVisitor(BaseObject): 4299 r""" Routing model visitor.""" 4300 4301 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 4302 __repr__ = _swig_repr 4303 4304 def __init__(self): 4305 _pywrapcp.RoutingModelVisitor_swiginit(self, _pywrapcp.new_RoutingModelVisitor()) 4306 __swig_destroy__ = _pywrapcp.delete_RoutingModelVisitor
Routing model visitor.
Inherited Members
4314class GlobalVehicleBreaksConstraint(Constraint): 4315 r""" GlobalVehicleBreaksConstraint ensures breaks constraints are enforced on all vehicles in the dimension passed to its constructor. It is intended to be used for dimensions representing time. A break constraint ensures break intervals fit on the route of a vehicle. For a given vehicle, it forces break intervals to be disjoint from visit intervals, where visit intervals start at CumulVar(node) and last for node_visit_transit[node]. Moreover, it ensures that there is enough time between two consecutive nodes of a route to do transit and vehicle breaks, i.e. if Next(nodeA) = nodeB, CumulVar(nodeA) = tA and CumulVar(nodeB) = tB, then SlackVar(nodeA) >= sum_{breaks [tA, tB)} duration(break).""" 4316 4317 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 4318 __repr__ = _swig_repr 4319 4320 def __init__(self, dimension: "RoutingDimension"): 4321 _pywrapcp.GlobalVehicleBreaksConstraint_swiginit(self, _pywrapcp.new_GlobalVehicleBreaksConstraint(dimension)) 4322 4323 def DebugString(self) -> "std::string": 4324 return _pywrapcp.GlobalVehicleBreaksConstraint_DebugString(self) 4325 4326 def Post(self) -> "void": 4327 return _pywrapcp.GlobalVehicleBreaksConstraint_Post(self) 4328 4329 def InitialPropagateWrapper(self) -> "void": 4330 return _pywrapcp.GlobalVehicleBreaksConstraint_InitialPropagateWrapper(self) 4331 __swig_destroy__ = _pywrapcp.delete_GlobalVehicleBreaksConstraint
GlobalVehicleBreaksConstraint ensures breaks constraints are enforced on all vehicles in the dimension passed to its constructor. It is intended to be used for dimensions representing time. A break constraint ensures break intervals fit on the route of a vehicle. For a given vehicle, it forces break intervals to be disjoint from visit intervals, where visit intervals start at CumulVar(node) and last for node_visit_transit[node]. Moreover, it ensures that there is enough time between two consecutive nodes of a route to do transit and vehicle breaks, i.e. if Next(nodeA) = nodeB, CumulVar(nodeA) = tA and CumulVar(nodeB) = tB, then SlackVar(nodeA) >= sum_{breaks [tA, tB)} duration(break).
This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.
4329 def InitialPropagateWrapper(self) -> "void": 4330 return _pywrapcp.GlobalVehicleBreaksConstraint_InitialPropagateWrapper(self)
This method performs the initial propagation of the constraint. It is called just after the post.
Inherited Members
4336class TypeRegulationsChecker(object): 4337 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 4338 4339 def __init__(self, *args, **kwargs): 4340 raise AttributeError("No constructor defined - class is abstract") 4341 __repr__ = _swig_repr 4342 __swig_destroy__ = _pywrapcp.delete_TypeRegulationsChecker 4343 4344 def CheckVehicle(self, vehicle: "int", next_accessor: "std::function< int64_t (int64_t) > const &") -> "bool": 4345 return _pywrapcp.TypeRegulationsChecker_CheckVehicle(self, vehicle, next_accessor)
4350class TypeIncompatibilityChecker(TypeRegulationsChecker): 4351 r""" Checker for type incompatibilities.""" 4352 4353 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 4354 __repr__ = _swig_repr 4355 4356 def __init__(self, model: "RoutingModel", check_hard_incompatibilities: "bool"): 4357 _pywrapcp.TypeIncompatibilityChecker_swiginit(self, _pywrapcp.new_TypeIncompatibilityChecker(model, check_hard_incompatibilities)) 4358 __swig_destroy__ = _pywrapcp.delete_TypeIncompatibilityChecker
Checker for type incompatibilities.
Inherited Members
4363class TypeRequirementChecker(TypeRegulationsChecker): 4364 r""" Checker for type requirements.""" 4365 4366 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 4367 __repr__ = _swig_repr 4368 4369 def __init__(self, model: "RoutingModel"): 4370 _pywrapcp.TypeRequirementChecker_swiginit(self, _pywrapcp.new_TypeRequirementChecker(model)) 4371 __swig_destroy__ = _pywrapcp.delete_TypeRequirementChecker
Checker for type requirements.
Inherited Members
4376class TypeRegulationsConstraint(Constraint): 4377 r""" The following constraint ensures that incompatibilities and requirements between types are respected. It verifies both "hard" and "temporal" incompatibilities. Two nodes with hard incompatible types cannot be served by the same vehicle at all, while with a temporal incompatibility they can't be on the same route at the same time. The VisitTypePolicy of a node determines how visiting it impacts the type count on the route. For example, for - three temporally incompatible types T1 T2 and T3 - 2 pairs of nodes a1/r1 and a2/r2 of type T1 and T2 respectively, with - a1 and a2 of VisitTypePolicy TYPE_ADDED_TO_VEHICLE - r1 and r2 of policy ADDED_TYPE_REMOVED_FROM_VEHICLE - 3 nodes A, UV and AR of type T3, respectively with type policies TYPE_ADDED_TO_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT and TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED the configurations UV --> a1 --> r1 --> a2 --> r2, a1 --> r1 --> a2 --> r2 --> A and a1 --> r1 --> AR --> a2 --> r2 are acceptable, whereas the configurations a1 --> a2 --> r1 --> ..., or A --> a1 --> r1 --> ..., or a1 --> r1 --> UV --> ... are not feasible. It also verifies same-vehicle and temporal type requirements. A node of type T_d with a same-vehicle requirement for type T_r needs to be served by the same vehicle as a node of type T_r. Temporal requirements, on the other hand, can take effect either when the dependent type is being added to the route or when it's removed from it, which is determined by the dependent node's VisitTypePolicy. In the above example: - If T3 is required on the same vehicle as T1, A, AR or UV must be on the same vehicle as a1. - If T2 is required when adding T1, a2 must be visited *before* a1, and if r2 is also visited on the route, it must be *after* a1, i.e. T2 must be on the vehicle when a1 is visited: ... --> a2 --> ... --> a1 --> ... --> r2 --> ... - If T3 is required when removing T1, T3 needs to be on the vehicle when r1 is visited: ... --> A --> ... --> r1 --> ... OR ... --> r1 --> ... --> UV --> ...""" 4378 4379 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 4380 __repr__ = _swig_repr 4381 4382 def __init__(self, model: "RoutingModel"): 4383 _pywrapcp.TypeRegulationsConstraint_swiginit(self, _pywrapcp.new_TypeRegulationsConstraint(model)) 4384 4385 def Post(self) -> "void": 4386 return _pywrapcp.TypeRegulationsConstraint_Post(self) 4387 4388 def InitialPropagateWrapper(self) -> "void": 4389 return _pywrapcp.TypeRegulationsConstraint_InitialPropagateWrapper(self) 4390 __swig_destroy__ = _pywrapcp.delete_TypeRegulationsConstraint
The following constraint ensures that incompatibilities and requirements between types are respected. It verifies both "hard" and "temporal" incompatibilities. Two nodes with hard incompatible types cannot be served by the same vehicle at all, while with a temporal incompatibility they can't be on the same route at the same time. The VisitTypePolicy of a node determines how visiting it impacts the type count on the route. For example, for - three temporally incompatible types T1 T2 and T3 - 2 pairs of nodes a1/r1 and a2/r2 of type T1 and T2 respectively, with - a1 and a2 of VisitTypePolicy TYPE_ADDED_TO_VEHICLE - r1 and r2 of policy ADDED_TYPE_REMOVED_FROM_VEHICLE - 3 nodes A, UV and AR of type T3, respectively with type policies TYPE_ADDED_TO_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT and TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED the configurations UV --> a1 --> r1 --> a2 --> r2, a1 --> r1 --> a2 --> r2 --> A and a1 --> r1 --> AR --> a2 --> r2 are acceptable, whereas the configurations a1 --> a2 --> r1 --> ..., or A --> a1 --> r1 --> ..., or a1 --> r1 --> UV --> ... are not feasible. It also verifies same-vehicle and temporal type requirements. A node of type T_d with a same-vehicle requirement for type T_r needs to be served by the same vehicle as a node of type T_r. Temporal requirements, on the other hand, can take effect either when the dependent type is being added to the route or when it's removed from it, which is determined by the dependent node's VisitTypePolicy. In the above example: - If T3 is required on the same vehicle as T1, A, AR or UV must be on the same vehicle as a1. - If T2 is required when adding T1, a2 must be visited before a1, and if r2 is also visited on the route, it must be after a1, i.e. T2 must be on the vehicle when a1 is visited: ... --> a2 --> ... --> a1 --> ... --> r2 --> ... - If T3 is required when removing T1, T3 needs to be on the vehicle when r1 is visited: ... --> A --> ... --> r1 --> ... OR ... --> r1 --> ... --> UV --> ...
This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.
4388 def InitialPropagateWrapper(self) -> "void": 4389 return _pywrapcp.TypeRegulationsConstraint_InitialPropagateWrapper(self)
This method performs the initial propagation of the constraint. It is called just after the post.
Inherited Members
4395class RoutingDimension(object): 4396 r""" Dimensions represent quantities accumulated at nodes along the routes. They represent quantities such as weights or volumes carried along the route, or distance or times. Quantities at a node are represented by "cumul" variables and the increase or decrease of quantities between nodes are represented by "transit" variables. These variables are linked as follows: if j == next(i), cumuls(j) = cumuls(i) + transits(i) + slacks(i) + state_dependent_transits(i) where slack is a positive slack variable (can represent waiting times for a time dimension), and state_dependent_transits is a non-purely functional version of transits_. Favour transits over state_dependent_transits when possible, because purely functional callbacks allow more optimisations and make the model faster and easier to solve. for a given vehicle, it is passed as an external vector, it would be better to have this information here.""" 4397 4398 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 4399 4400 def __init__(self, *args, **kwargs): 4401 raise AttributeError("No constructor defined") 4402 __repr__ = _swig_repr 4403 __swig_destroy__ = _pywrapcp.delete_RoutingDimension 4404 4405 def model(self) -> "operations_research::RoutingModel *": 4406 r""" Returns the model on which the dimension was created.""" 4407 return _pywrapcp.RoutingDimension_model(self) 4408 4409 def GetTransitValue(self, from_index: "int64_t", to_index: "int64_t", vehicle: "int64_t") -> "int64_t": 4410 r""" Returns the transition value for a given pair of nodes (as var index); this value is the one taken by the corresponding transit variable when the 'next' variable for 'from_index' is bound to 'to_index'.""" 4411 return _pywrapcp.RoutingDimension_GetTransitValue(self, from_index, to_index, vehicle) 4412 4413 def GetTransitValueFromClass(self, from_index: "int64_t", to_index: "int64_t", vehicle_class: "int64_t") -> "int64_t": 4414 r""" Same as above but taking a vehicle class of the dimension instead of a vehicle (the class of a vehicle can be obtained with vehicle_to_class()).""" 4415 return _pywrapcp.RoutingDimension_GetTransitValueFromClass(self, from_index, to_index, vehicle_class) 4416 4417 def CumulVar(self, index: "int64_t") -> "operations_research::IntVar *": 4418 r""" Get the cumul, transit and slack variables for the given node (given as int64_t var index).""" 4419 return _pywrapcp.RoutingDimension_CumulVar(self, index) 4420 4421 def TransitVar(self, index: "int64_t") -> "operations_research::IntVar *": 4422 return _pywrapcp.RoutingDimension_TransitVar(self, index) 4423 4424 def FixedTransitVar(self, index: "int64_t") -> "operations_research::IntVar *": 4425 return _pywrapcp.RoutingDimension_FixedTransitVar(self, index) 4426 4427 def SlackVar(self, index: "int64_t") -> "operations_research::IntVar *": 4428 return _pywrapcp.RoutingDimension_SlackVar(self, index) 4429 4430 def SetSpanUpperBoundForVehicle(self, upper_bound: "int64_t", vehicle: "int") -> "void": 4431 r""" Sets an upper bound on the dimension span on a given vehicle. This is the preferred way to limit the "length" of the route of a vehicle according to a dimension.""" 4432 return _pywrapcp.RoutingDimension_SetSpanUpperBoundForVehicle(self, upper_bound, vehicle) 4433 4434 def SetSpanCostCoefficientForVehicle(self, coefficient: "int64_t", vehicle: "int") -> "void": 4435 r""" Sets a cost proportional to the dimension span on a given vehicle, or on all vehicles at once. "coefficient" must be nonnegative. This is handy to model costs proportional to idle time when the dimension represents time. The cost for a vehicle is span_cost = coefficient * (dimension end value - dimension start value).""" 4436 return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForVehicle(self, coefficient, vehicle) 4437 4438 def SetSpanCostCoefficientForAllVehicles(self, coefficient: "int64_t") -> "void": 4439 return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForAllVehicles(self, coefficient) 4440 4441 def SetGlobalSpanCostCoefficient(self, coefficient: "int64_t") -> "void": 4442 r""" Sets a cost proportional to the *global* dimension span, that is the difference between the largest value of route end cumul variables and the smallest value of route start cumul variables. In other words: global_span_cost = coefficient * (Max(dimension end value) - Min(dimension start value)).""" 4443 return _pywrapcp.RoutingDimension_SetGlobalSpanCostCoefficient(self, coefficient) 4444 4445 def SetCumulVarSoftUpperBound(self, index: "int64_t", upper_bound: "int64_t", coefficient: "int64_t") -> "void": 4446 r""" Sets a soft upper bound to the cumul variable of a given variable index. If the value of the cumul variable is greater than the bound, a cost proportional to the difference between this value and the bound is added to the cost function of the model: cumulVar <= upper_bound -> cost = 0 cumulVar > upper_bound -> cost = coefficient * (cumulVar - upper_bound) This is also handy to model tardiness costs when the dimension represents time.""" 4447 return _pywrapcp.RoutingDimension_SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient) 4448 4449 def HasCumulVarSoftUpperBound(self, index: "int64_t") -> "bool": 4450 r""" Returns true if a soft upper bound has been set for a given variable index.""" 4451 return _pywrapcp.RoutingDimension_HasCumulVarSoftUpperBound(self, index) 4452 4453 def GetCumulVarSoftUpperBound(self, index: "int64_t") -> "int64_t": 4454 r""" Returns the soft upper bound of a cumul variable for a given variable index. The "hard" upper bound of the variable is returned if no soft upper bound has been set.""" 4455 return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBound(self, index) 4456 4457 def GetCumulVarSoftUpperBoundCoefficient(self, index: "int64_t") -> "int64_t": 4458 r""" Returns the cost coefficient of the soft upper bound of a cumul variable for a given variable index. If no soft upper bound has been set, 0 is returned.""" 4459 return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBoundCoefficient(self, index) 4460 4461 def SetCumulVarSoftLowerBound(self, index: "int64_t", lower_bound: "int64_t", coefficient: "int64_t") -> "void": 4462 r""" Sets a soft lower bound to the cumul variable of a given variable index. If the value of the cumul variable is less than the bound, a cost proportional to the difference between this value and the bound is added to the cost function of the model: cumulVar > lower_bound -> cost = 0 cumulVar <= lower_bound -> cost = coefficient * (lower_bound - cumulVar). This is also handy to model earliness costs when the dimension represents time.""" 4463 return _pywrapcp.RoutingDimension_SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient) 4464 4465 def HasCumulVarSoftLowerBound(self, index: "int64_t") -> "bool": 4466 r""" Returns true if a soft lower bound has been set for a given variable index.""" 4467 return _pywrapcp.RoutingDimension_HasCumulVarSoftLowerBound(self, index) 4468 4469 def GetCumulVarSoftLowerBound(self, index: "int64_t") -> "int64_t": 4470 r""" Returns the soft lower bound of a cumul variable for a given variable index. The "hard" lower bound of the variable is returned if no soft lower bound has been set.""" 4471 return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBound(self, index) 4472 4473 def GetCumulVarSoftLowerBoundCoefficient(self, index: "int64_t") -> "int64_t": 4474 r""" Returns the cost coefficient of the soft lower bound of a cumul variable for a given variable index. If no soft lower bound has been set, 0 is returned.""" 4475 return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBoundCoefficient(self, index) 4476 4477 def SetBreakIntervalsOfVehicle(self, breaks: "std::vector< operations_research::IntervalVar * >", vehicle: "int", node_visit_transits: "std::vector< int64_t >") -> "void": 4478 r""" Sets the breaks for a given vehicle. Breaks are represented by IntervalVars. They may interrupt transits between nodes and increase the value of corresponding slack variables. A break may take place before the start of a vehicle, after the end of a vehicle, or during a travel i -> j. In that case, the interval [break.Start(), break.End()) must be a subset of [CumulVar(i) + pre_travel(i, j), CumulVar(j) - post_travel(i, j)). In other words, a break may not overlap any node n's visit, given by [CumulVar(n) - post_travel(_, n), CumulVar(n) + pre_travel(n, _)). This formula considers post_travel(_, start) and pre_travel(end, _) to be 0; pre_travel will never be called on any (_, start) and post_travel will never we called on any (end, _). If pre_travel_evaluator or post_travel_evaluator is -1, it will be taken as a function that always returns 0. Deprecated, sets pre_travel(i, j) = node_visit_transit[i].""" 4479 return _pywrapcp.RoutingDimension_SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits) 4480 4481 def SetBreakDistanceDurationOfVehicle(self, distance: "int64_t", duration: "int64_t", vehicle: "int") -> "void": 4482 r""" With breaks supposed to be consecutive, this forces the distance between breaks of size at least minimum_break_duration to be at most distance. This supposes that the time until route start and after route end are infinite breaks.""" 4483 return _pywrapcp.RoutingDimension_SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle) 4484 4485 def InitializeBreaks(self) -> "void": 4486 r""" Sets up vehicle_break_intervals_, vehicle_break_distance_duration_, pre_travel_evaluators and post_travel_evaluators.""" 4487 return _pywrapcp.RoutingDimension_InitializeBreaks(self) 4488 4489 def HasBreakConstraints(self) -> "bool": 4490 r""" Returns true if any break interval or break distance was defined.""" 4491 return _pywrapcp.RoutingDimension_HasBreakConstraints(self) 4492 4493 def GetBreakIntervalsOfVehicle(self, vehicle: "int") -> "std::vector< operations_research::IntervalVar * > const &": 4494 r""" Returns the break intervals set by SetBreakIntervalsOfVehicle().""" 4495 return _pywrapcp.RoutingDimension_GetBreakIntervalsOfVehicle(self, vehicle) 4496 4497 def GetBreakDistanceDurationOfVehicle(self, vehicle: "int") -> "std::vector< std::pair< int64_t,int64_t > > const &": 4498 r""" Returns the pairs (distance, duration) specified by break distance constraints.""" 4499 return _pywrapcp.RoutingDimension_GetBreakDistanceDurationOfVehicle(self, vehicle) 4500 4501 def GetPreTravelEvaluatorOfVehicle(self, vehicle: "int") -> "int": 4502 return _pywrapcp.RoutingDimension_GetPreTravelEvaluatorOfVehicle(self, vehicle) 4503 4504 def GetPostTravelEvaluatorOfVehicle(self, vehicle: "int") -> "int": 4505 return _pywrapcp.RoutingDimension_GetPostTravelEvaluatorOfVehicle(self, vehicle) 4506 4507 def base_dimension(self) -> "operations_research::RoutingDimension const *": 4508 r""" Returns the parent in the dependency tree if any or nullptr otherwise.""" 4509 return _pywrapcp.RoutingDimension_base_dimension(self) 4510 4511 def ShortestTransitionSlack(self, node: "int64_t") -> "int64_t": 4512 r""" It makes sense to use the function only for self-dependent dimension. For such dimensions the value of the slack of a node determines the transition cost of the next transit. Provided that 1. cumul[node] is fixed, 2. next[node] and next[next[node]] (if exists) are fixed, the value of slack[node] for which cumul[next[node]] + transit[next[node]] is minimized can be found in O(1) using this function.""" 4513 return _pywrapcp.RoutingDimension_ShortestTransitionSlack(self, node) 4514 4515 def name(self) -> "std::string const &": 4516 r""" Returns the name of the dimension.""" 4517 return _pywrapcp.RoutingDimension_name(self) 4518 4519 def SetPickupToDeliveryLimitFunctionForPair(self, limit_function: "operations_research::RoutingDimension::PickupToDeliveryLimitFunction", pair_index: "int") -> "void": 4520 return _pywrapcp.RoutingDimension_SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index) 4521 4522 def HasPickupToDeliveryLimits(self) -> "bool": 4523 return _pywrapcp.RoutingDimension_HasPickupToDeliveryLimits(self) 4524 4525 def AddNodePrecedence(self, first_node: "int64_t", second_node: "int64_t", offset: "int64_t") -> "void": 4526 return _pywrapcp.RoutingDimension_AddNodePrecedence(self, first_node, second_node, offset) 4527 4528 def GetSpanUpperBoundForVehicle(self, vehicle: "int") -> "int64_t": 4529 return _pywrapcp.RoutingDimension_GetSpanUpperBoundForVehicle(self, vehicle) 4530 4531 def GetSpanCostCoefficientForVehicle(self, vehicle: "int") -> "int64_t": 4532 return _pywrapcp.RoutingDimension_GetSpanCostCoefficientForVehicle(self, vehicle) 4533 4534 def global_span_cost_coefficient(self) -> "int64_t": 4535 return _pywrapcp.RoutingDimension_global_span_cost_coefficient(self) 4536 4537 def GetGlobalOptimizerOffset(self) -> "int64_t": 4538 return _pywrapcp.RoutingDimension_GetGlobalOptimizerOffset(self) 4539 4540 def GetLocalOptimizerOffsetForVehicle(self, vehicle: "int") -> "int64_t": 4541 return _pywrapcp.RoutingDimension_GetLocalOptimizerOffsetForVehicle(self, vehicle)
Dimensions represent quantities accumulated at nodes along the routes. They represent quantities such as weights or volumes carried along the route, or distance or times. Quantities at a node are represented by "cumul" variables and the increase or decrease of quantities between nodes are represented by "transit" variables. These variables are linked as follows: if j == next(i), cumuls(j) = cumuls(i) + transits(i) + slacks(i) + state_dependent_transits(i) where slack is a positive slack variable (can represent waiting times for a time dimension), and state_dependent_transits is a non-purely functional version of transits_. Favour transits over state_dependent_transits when possible, because purely functional callbacks allow more optimisations and make the model faster and easier to solve. for a given vehicle, it is passed as an external vector, it would be better to have this information here.
4405 def model(self) -> "operations_research::RoutingModel *": 4406 r""" Returns the model on which the dimension was created.""" 4407 return _pywrapcp.RoutingDimension_model(self)
Returns the model on which the dimension was created.
4409 def GetTransitValue(self, from_index: "int64_t", to_index: "int64_t", vehicle: "int64_t") -> "int64_t": 4410 r""" Returns the transition value for a given pair of nodes (as var index); this value is the one taken by the corresponding transit variable when the 'next' variable for 'from_index' is bound to 'to_index'.""" 4411 return _pywrapcp.RoutingDimension_GetTransitValue(self, from_index, to_index, vehicle)
Returns the transition value for a given pair of nodes (as var index); this value is the one taken by the corresponding transit variable when the 'next' variable for 'from_index' is bound to 'to_index'.
4413 def GetTransitValueFromClass(self, from_index: "int64_t", to_index: "int64_t", vehicle_class: "int64_t") -> "int64_t": 4414 r""" Same as above but taking a vehicle class of the dimension instead of a vehicle (the class of a vehicle can be obtained with vehicle_to_class()).""" 4415 return _pywrapcp.RoutingDimension_GetTransitValueFromClass(self, from_index, to_index, vehicle_class)
Same as above but taking a vehicle class of the dimension instead of a vehicle (the class of a vehicle can be obtained with vehicle_to_class()).
4417 def CumulVar(self, index: "int64_t") -> "operations_research::IntVar *": 4418 r""" Get the cumul, transit and slack variables for the given node (given as int64_t var index).""" 4419 return _pywrapcp.RoutingDimension_CumulVar(self, index)
Get the cumul, transit and slack variables for the given node (given as int64_t var index).
4430 def SetSpanUpperBoundForVehicle(self, upper_bound: "int64_t", vehicle: "int") -> "void": 4431 r""" Sets an upper bound on the dimension span on a given vehicle. This is the preferred way to limit the "length" of the route of a vehicle according to a dimension.""" 4432 return _pywrapcp.RoutingDimension_SetSpanUpperBoundForVehicle(self, upper_bound, vehicle)
Sets an upper bound on the dimension span on a given vehicle. This is the preferred way to limit the "length" of the route of a vehicle according to a dimension.
4434 def SetSpanCostCoefficientForVehicle(self, coefficient: "int64_t", vehicle: "int") -> "void": 4435 r""" Sets a cost proportional to the dimension span on a given vehicle, or on all vehicles at once. "coefficient" must be nonnegative. This is handy to model costs proportional to idle time when the dimension represents time. The cost for a vehicle is span_cost = coefficient * (dimension end value - dimension start value).""" 4436 return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForVehicle(self, coefficient, vehicle)
Sets a cost proportional to the dimension span on a given vehicle, or on all vehicles at once. "coefficient" must be nonnegative. This is handy to model costs proportional to idle time when the dimension represents time. The cost for a vehicle is span_cost = coefficient * (dimension end value - dimension start value).
4441 def SetGlobalSpanCostCoefficient(self, coefficient: "int64_t") -> "void": 4442 r""" Sets a cost proportional to the *global* dimension span, that is the difference between the largest value of route end cumul variables and the smallest value of route start cumul variables. In other words: global_span_cost = coefficient * (Max(dimension end value) - Min(dimension start value)).""" 4443 return _pywrapcp.RoutingDimension_SetGlobalSpanCostCoefficient(self, coefficient)
Sets a cost proportional to the global dimension span, that is the difference between the largest value of route end cumul variables and the smallest value of route start cumul variables. In other words: global_span_cost = coefficient * (Max(dimension end value) - Min(dimension start value)).
4445 def SetCumulVarSoftUpperBound(self, index: "int64_t", upper_bound: "int64_t", coefficient: "int64_t") -> "void": 4446 r""" Sets a soft upper bound to the cumul variable of a given variable index. If the value of the cumul variable is greater than the bound, a cost proportional to the difference between this value and the bound is added to the cost function of the model: cumulVar <= upper_bound -> cost = 0 cumulVar > upper_bound -> cost = coefficient * (cumulVar - upper_bound) This is also handy to model tardiness costs when the dimension represents time.""" 4447 return _pywrapcp.RoutingDimension_SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient)
Sets a soft upper bound to the cumul variable of a given variable index. If the value of the cumul variable is greater than the bound, a cost proportional to the difference between this value and the bound is added to the cost function of the model: cumulVar <= upper_bound -> cost = 0 cumulVar > upper_bound -> cost = coefficient * (cumulVar - upper_bound) This is also handy to model tardiness costs when the dimension represents time.
4449 def HasCumulVarSoftUpperBound(self, index: "int64_t") -> "bool": 4450 r""" Returns true if a soft upper bound has been set for a given variable index.""" 4451 return _pywrapcp.RoutingDimension_HasCumulVarSoftUpperBound(self, index)
Returns true if a soft upper bound has been set for a given variable index.
4453 def GetCumulVarSoftUpperBound(self, index: "int64_t") -> "int64_t": 4454 r""" Returns the soft upper bound of a cumul variable for a given variable index. The "hard" upper bound of the variable is returned if no soft upper bound has been set.""" 4455 return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBound(self, index)
Returns the soft upper bound of a cumul variable for a given variable index. The "hard" upper bound of the variable is returned if no soft upper bound has been set.
4457 def GetCumulVarSoftUpperBoundCoefficient(self, index: "int64_t") -> "int64_t": 4458 r""" Returns the cost coefficient of the soft upper bound of a cumul variable for a given variable index. If no soft upper bound has been set, 0 is returned.""" 4459 return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBoundCoefficient(self, index)
Returns the cost coefficient of the soft upper bound of a cumul variable for a given variable index. If no soft upper bound has been set, 0 is returned.
4461 def SetCumulVarSoftLowerBound(self, index: "int64_t", lower_bound: "int64_t", coefficient: "int64_t") -> "void": 4462 r""" Sets a soft lower bound to the cumul variable of a given variable index. If the value of the cumul variable is less than the bound, a cost proportional to the difference between this value and the bound is added to the cost function of the model: cumulVar > lower_bound -> cost = 0 cumulVar <= lower_bound -> cost = coefficient * (lower_bound - cumulVar). This is also handy to model earliness costs when the dimension represents time.""" 4463 return _pywrapcp.RoutingDimension_SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient)
Sets a soft lower bound to the cumul variable of a given variable index. If the value of the cumul variable is less than the bound, a cost proportional to the difference between this value and the bound is added to the cost function of the model: cumulVar > lower_bound -> cost = 0 cumulVar <= lower_bound -> cost = coefficient * (lower_bound - cumulVar). This is also handy to model earliness costs when the dimension represents time.
4465 def HasCumulVarSoftLowerBound(self, index: "int64_t") -> "bool": 4466 r""" Returns true if a soft lower bound has been set for a given variable index.""" 4467 return _pywrapcp.RoutingDimension_HasCumulVarSoftLowerBound(self, index)
Returns true if a soft lower bound has been set for a given variable index.
4469 def GetCumulVarSoftLowerBound(self, index: "int64_t") -> "int64_t": 4470 r""" Returns the soft lower bound of a cumul variable for a given variable index. The "hard" lower bound of the variable is returned if no soft lower bound has been set.""" 4471 return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBound(self, index)
Returns the soft lower bound of a cumul variable for a given variable index. The "hard" lower bound of the variable is returned if no soft lower bound has been set.
4473 def GetCumulVarSoftLowerBoundCoefficient(self, index: "int64_t") -> "int64_t": 4474 r""" Returns the cost coefficient of the soft lower bound of a cumul variable for a given variable index. If no soft lower bound has been set, 0 is returned.""" 4475 return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBoundCoefficient(self, index)
Returns the cost coefficient of the soft lower bound of a cumul variable for a given variable index. If no soft lower bound has been set, 0 is returned.
4477 def SetBreakIntervalsOfVehicle(self, breaks: "std::vector< operations_research::IntervalVar * >", vehicle: "int", node_visit_transits: "std::vector< int64_t >") -> "void": 4478 r""" Sets the breaks for a given vehicle. Breaks are represented by IntervalVars. They may interrupt transits between nodes and increase the value of corresponding slack variables. A break may take place before the start of a vehicle, after the end of a vehicle, or during a travel i -> j. In that case, the interval [break.Start(), break.End()) must be a subset of [CumulVar(i) + pre_travel(i, j), CumulVar(j) - post_travel(i, j)). In other words, a break may not overlap any node n's visit, given by [CumulVar(n) - post_travel(_, n), CumulVar(n) + pre_travel(n, _)). This formula considers post_travel(_, start) and pre_travel(end, _) to be 0; pre_travel will never be called on any (_, start) and post_travel will never we called on any (end, _). If pre_travel_evaluator or post_travel_evaluator is -1, it will be taken as a function that always returns 0. Deprecated, sets pre_travel(i, j) = node_visit_transit[i].""" 4479 return _pywrapcp.RoutingDimension_SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits)
Sets the breaks for a given vehicle. Breaks are represented by IntervalVars. They may interrupt transits between nodes and increase the value of corresponding slack variables. A break may take place before the start of a vehicle, after the end of a vehicle, or during a travel i -> j. In that case, the interval [break.Start(), break.End()) must be a subset of [CumulVar(i) + pre_travel(i, j), CumulVar(j) - post_travel(i, j)). In other words, a break may not overlap any node n's visit, given by [CumulVar(n) - post_travel(_, n), CumulVar(n) + pre_travel(n, _)). This formula considers post_travel(_, start) and pre_travel(end, _) to be 0; pre_travel will never be called on any (_, start) and post_travel will never we called on any (end, _). If pre_travel_evaluator or post_travel_evaluator is -1, it will be taken as a function that always returns 0. Deprecated, sets pre_travel(i, j) = node_visit_transit[i].
4481 def SetBreakDistanceDurationOfVehicle(self, distance: "int64_t", duration: "int64_t", vehicle: "int") -> "void": 4482 r""" With breaks supposed to be consecutive, this forces the distance between breaks of size at least minimum_break_duration to be at most distance. This supposes that the time until route start and after route end are infinite breaks.""" 4483 return _pywrapcp.RoutingDimension_SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle)
With breaks supposed to be consecutive, this forces the distance between breaks of size at least minimum_break_duration to be at most distance. This supposes that the time until route start and after route end are infinite breaks.
4485 def InitializeBreaks(self) -> "void": 4486 r""" Sets up vehicle_break_intervals_, vehicle_break_distance_duration_, pre_travel_evaluators and post_travel_evaluators.""" 4487 return _pywrapcp.RoutingDimension_InitializeBreaks(self)
Sets up vehicle_break_intervals_, vehicle_break_distance_duration_, pre_travel_evaluators and post_travel_evaluators.
4489 def HasBreakConstraints(self) -> "bool": 4490 r""" Returns true if any break interval or break distance was defined.""" 4491 return _pywrapcp.RoutingDimension_HasBreakConstraints(self)
Returns true if any break interval or break distance was defined.
4493 def GetBreakIntervalsOfVehicle(self, vehicle: "int") -> "std::vector< operations_research::IntervalVar * > const &": 4494 r""" Returns the break intervals set by SetBreakIntervalsOfVehicle().""" 4495 return _pywrapcp.RoutingDimension_GetBreakIntervalsOfVehicle(self, vehicle)
Returns the break intervals set by SetBreakIntervalsOfVehicle().
4497 def GetBreakDistanceDurationOfVehicle(self, vehicle: "int") -> "std::vector< std::pair< int64_t,int64_t > > const &": 4498 r""" Returns the pairs (distance, duration) specified by break distance constraints.""" 4499 return _pywrapcp.RoutingDimension_GetBreakDistanceDurationOfVehicle(self, vehicle)
Returns the pairs (distance, duration) specified by break distance constraints.
4507 def base_dimension(self) -> "operations_research::RoutingDimension const *": 4508 r""" Returns the parent in the dependency tree if any or nullptr otherwise.""" 4509 return _pywrapcp.RoutingDimension_base_dimension(self)
Returns the parent in the dependency tree if any or nullptr otherwise.
4511 def ShortestTransitionSlack(self, node: "int64_t") -> "int64_t": 4512 r""" It makes sense to use the function only for self-dependent dimension. For such dimensions the value of the slack of a node determines the transition cost of the next transit. Provided that 1. cumul[node] is fixed, 2. next[node] and next[next[node]] (if exists) are fixed, the value of slack[node] for which cumul[next[node]] + transit[next[node]] is minimized can be found in O(1) using this function.""" 4513 return _pywrapcp.RoutingDimension_ShortestTransitionSlack(self, node)
It makes sense to use the function only for self-dependent dimension. For such dimensions the value of the slack of a node determines the transition cost of the next transit. Provided that 1. cumul[node] is fixed, 2. next[node] and next[next[node]] (if exists) are fixed, the value of slack[node] for which cumul[next[node]] + transit[next[node]] is minimized can be found in O(1) using this function.
4515 def name(self) -> "std::string const &": 4516 r""" Returns the name of the dimension.""" 4517 return _pywrapcp.RoutingDimension_name(self)
Returns the name of the dimension.
4547def MakeSetValuesFromTargets(solver: "Solver", variables: "std::vector< operations_research::IntVar * >", targets: "std::vector< int64_t >") -> "operations_research::DecisionBuilder *": 4548 r""" A decision builder which tries to assign values to variables as close as possible to target values first.""" 4549 return _pywrapcp.MakeSetValuesFromTargets(solver, variables, targets)
A decision builder which tries to assign values to variables as close as possible to target values first.
4551def SolveModelWithSat(model: "RoutingModel", search_parameters: "operations_research::RoutingSearchParameters const &", initial_solution: "Assignment", solution: "Assignment") -> "bool": 4552 r""" Attempts to solve the model using the cp-sat solver. As of 5/2019, will solve the TSP corresponding to the model if it has a single vehicle. Therefore the resulting solution might not actually be feasible. Will return false if a solution could not be found.""" 4553 return _pywrapcp.SolveModelWithSat(model, search_parameters, initial_solution, solution)
Attempts to solve the model using the cp-sat solver. As of 5/2019, will solve the TSP corresponding to the model if it has a single vehicle. Therefore the resulting solution might not actually be feasible. Will return false if a solution could not be found.